How to pass variable value to another view? |
[eluser]Unknown[/eluser]
Hi Everyone, I m stuck somewhere passing values between different view. Let me explain my problem. I have a controller: category.php Code: <?php In this controller I am passing two value first is category name and second is page name which I will use in my template. Here is my template code include/template.php Code: <?php In my header view I am changing the value of catname variable. header.php Code: <?php home.php Code: <?php Now problem is that when I am trying to print catname using my second view its showing me old value not updated one. So can anyone please suggest me how can I accomplish this. I have tried GLOBAL varibale too but unable to solve this problem. I am new to php and codeigniter so please suggest me. Many thanks in advance.
[eluser]Eric Barnes[/eluser]
If you are changing the variable in another then you would have to pass it to the sub view. Code: $this->load->view($page, $catname); ?> Although more than likely this would best done in the controller.
[eluser]Unknown[/eluser]
Hi Eric, Thanks for reply. But I am using only one template for whole website and this requirement is only for 3-4 pages and every page have different-2 variable.. Is there any other way to get this.
[eluser]ranjudsokomora[/eluser]
Alok Rawat, I would suggest setting a config value at runtime with the original 'catname', and when you load your second view call the config value. It would look something like this. controller: category.php Code: <?php header.php Code: <?PHP home.php Code: <?php
[eluser]daydreamer[/eluser]
I have same question a week ago and found the solution at http://ellislab.com/forums/viewthread/88335/#445375 |
Welcome Guest, Not a member yet? Register Sign In |