We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7448
    • 4 Posts
    Hi,

    I am trying to get something out of a database using a template variable;

    $catname = '[[*testvar]]';


    $result = mysql_query("SELECT id FROM gegevens WHERE section_naam = '$catname' ");


    But this doesn't work. The value of the template variable is "Fotograaf".

    If I do this;

    $catname = 'Fotograaf';


    $result = mysql_query("SELECT id FROM gegevens WHERE section_naam = '$catname' ");


    It gives me the result I want...

    So even when the value of the templatevariable is "Fotograaf" it seems it's actually something else. I am not so experienced with php programming so I tried to find out why it doesn't match. I used
    crc32($catname) 
    to find out if there is any difference between the values of "Fotograaf".

    The output when using crc32 for the value of the template variabele
    ($catname = '[[*testvar]]';)
    is 1103516372. The outcome after giving it a value myself
    ($catname = 'Fotograaf';)
    is -657888939. That is the same value of the field in the database I am searching in. If I read the value of the template variable directly from the modx database it also gives that value.

    So the variable is stored in the modx database in the right way. But when using it as a template variable something goes wrong...

    The template variable is "Text", I am using MODX Revolution 2.2.0-pl2 (traditional)...



    [ed. note: dimitrivisser last edited this post 14 years, 6 months ago.]
      • 4172
      • 5,888 Posts
      you can put the value into a property of your snippet-tag like that:

      [[yourtv? &catname = `[[*testvar]]`]]


      or you can get the TV-Value inside your snippet with:

      $catname = $modx->resource->getTvValue('testvar');
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 7448
        • 4 Posts
        Thank you very very much! I've been busy with it for a day myself without finding a solution...