I want to pass a language id for each link i click from my view to controller.
My view code is
<?php foreach ($languages as $lang) { ?>
<li>
<a href="<?php echo base_url(); ?>home/box/<?php echo $template_data['box_id']?>/<?php echo $lang['language_name']?>"></a>
</li>
<?php } ?>
My controller is
public function box($box_id=null, $language_name=null, $language_id=null) {
/// my function code
echo $box_id;
echo $language_name;
echo $language_id;
$data['languages'] = $this->Home_model->getLanguages($box_id);
}
The languages array contain the language id and language name
i want the name to be in url but not the id
The url looks like this
http://localhost/mediabox/home/box/12/en
if i send the language id in url it is then visible otherwise it is not visible in the controller.
How can I get language id for each link in controller without sending it in url
Thanks
pass the language name in the url without the ID, compare to languag_name column in table.
Lets assume you have url:
http://localhost/mediabox/home/box/encontroller
library/private function
lang model
you will then have a variable with object associated to it then you can simply call
$lang->lang_name;or$lang->lang_id;Session storage