codescope
(Deepbluegene)
1
Hi
I am using $_GET[‘variable’] in controller to access a query string variable but the value is not getting passes.
for example
link is http://example.com/index.php/page/index?variable=123
is this approach right?
i read somewhere that variables can be passed using http://example.com/index.php/page/index/variable/123 but never implemented that as i m not sure
robregonm
(Ricobregon)
2
You can pass variables using the second way if you set them up in the config/main.php file, in the section urlManager:
something like:
'rules' => array(
'<controller:\w+>/<action:\w+>/<varname:\w+>/<id:\d+>' => '<controller>/<action>/<varname>/<id>',
)
Hope this helps
codescope
(Deepbluegene)
3
Thanks for reply. that worked. It also worked when i commented out your tip. may be it is on by default
another related issue
echo CHtml::link('<img src="' . Yii::app()->request->baseUrl . '/images/icons/page.png" alt="' . $pages["name"] . '" /><br>', array('index', 'id' => $pages["id"], 'pagenumbner' => $_GET['pagenumber'], 'chapter'=>$pages["chapter"]));
above code produces
index.php/pages/index/12?pagenumber=3&chapter=4
why first variable is just 12 instead of id=12?
i am getting confused .