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

    I'm having an issue: I created a snippet with a link to refresh the page:

    <?php
    	$output = "<a href=\"".$_SERVER['PHP_SELF']."?a=test\">Refresh</a>";
    	
    	return $output;
    

    When I do that, $output return "index.php"

    So, after doing some research, I found this solution:

    <?php
    	$url = $modx->makeUrl($modx->resource->get('id'),'',array('a' => 'test'));
    	$output = <a href=\"".$url."\">Refresh</a>
    
    	return $output;


    However, it doesn't completely work like a PHP_SELF, because it loads the page at the top of the page. If I'm in the middle of a page and I reload it, I don't want to have to scroll back down to where I was at.

    I also found the following function:

    $modx->sendRedirect($url)


    but I can't put that in an <a> tag.

    Is there any other way to achieve a reload of the same page at the same location?

    Thank you.
      Jean-Marc Buytaert (@jmbuytaert)

      MODX truly is the greatest thing that's ever happened to the Internet.
      • 40627
      • 2 Posts
      Is it possible to use javascript instead?

      <a id="frenchman" href="javascript:window.location.replace(window.location.href + '?a=test'">Reload</a>