Pass arguments from one page to another

Permalink 1 user found helpful
Hello all,

I am trying to generate a list of links that when clicked, they should take the user to another page where the detail of the clicked item is shown.

foreach ($table as $row)
{
    echo '<a href="'.UrlHelper::buildQuery('user-selection/user-information',array('userid'=>$row[0])).'">';
    echo $row[1];
    echo "</a>";
    echo "<br />";
}


The problem with the above code is that in spite of the page 'user-information' existing, if i try pass arguments to it, concrete5 says the page does not exist.

How can I pass arguments from one page to another?

thanks in advance

 
jordanlev replied on at Permalink Reply
jordanlev
I don't think that UrlHelper function does what you think it does -- it's actually kind of useless, as all it's doing is appending the parameter to the end of the url with a question mark in the middle.

It does not formulate a complete URL if you only pass it a path though. Instead just do this:
echo '<a href="' . DIR_REL . '/user-selection/user-information?userid=' . $row[0] . '">';
jordanlev replied on at Permalink Reply
jordanlev
Or if you want code that is more complicated but possibly more robust (i.e. it handles different pretty url settings), try this:
$url = Loader::helper('navigation')->getCollectionURL(Page::getByPath('user-selection/user-information'));
$url .= (strstr($url, '?') ? '&' : '?') . 'userid=' . $row[0];
echo '<a href="' . $url . '">';