We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12584
    • 208 Posts
    I have created a snippet that holds some php code with the {$_SERVER[’PHP_SELF’]} function, when clicked it just reloads the index.php page ie I see the homepage.

    The full line looks like this

    echo "<a href=\"{$_SERVER['PHP_SELF']}?year=members2006\">2006 Members</a><br />";
    
    


    Is there a wat round this without putting in the full url

    Cheers
      • 22303 MODX Staff
      • 10,725 Posts
      Since all requests in MODx got through the index.php, PHP_SELF is always the same for every MODx page. In MODx, to refer to links to specific pages, you use the link tags in content, and you can embed a document tag representing the current document id, e.g.
      <a href="[~[*id*]~]&year=members2006">2006 Members</a><br />

      or, in code using the $modx->makeUrl() function, e.g.
      echo '<a href="' . $modx->makeUrl($modx->documentIdentifier, '', 'year=members2006') . '">2006 Members</a><br />';
        • 12584
        • 208 Posts
        ok I think i must be going stupid, I have looked at all examples and now have the following code

        $url = $modx->makeUrl(32,’’,’&page=32&year=members2006’);

        I have tried many differant formats but as it is above i just get an unexpected ’<’, expecting ’,’ or ’;’ in error.
        I have also treid to echo out the $url and tried both examples in the reply but as a simpleton I am just not getting something. Sorry if this post is really overlooking the obvious but I am not very good with code.

        Cheers
          • 22303 MODX Staff
          • 10,725 Posts
          Well, first try without the first & in the param list, i.e.
          $url = $modx->makeUrl(32,'','year=members2006');
          

          Second, what is page=32 supposed to be anyway?

          But the error you describe sounds more like a PHP syntax error. Without full details I can’t tell you where however...