I am writing a component with two views - a list view, and an article view.
The list view generates the links for each article as follows, with $text being the variable I want in the URL.
<?php echo JRoute::_("index.php?Itemid=103&testvar=".strtolower($text)); ?>
ie http://www.test.com/test is the list page and I want http://www.test.com/test/text as the article page
103 is the menu item id where the component is. This is set to the list view.
My router contains the following code:
if(isset($query['testvar']))
{
$segments[] = $query['testvar'];
unset($query['testvar']);
};
This generates the following URL: http://www.test.com/test/text?testvar=text
unset($query['testvar']);
does not seem to be working to remove the ?testvar=text
bit. Everything else is working as expected.
A workaround would be <?php echo JRoute::_("index.php?Itemid=103")."/".strtolower($text); ?>
- but that seems hacky.
Any ideas?