CodeIgniter Forums
Using PHP code in the Template library configuration file? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Using PHP code in the Template library configuration file? (/showthread.php?tid=32627)



Using PHP code in the Template library configuration file? - El Forum - 07-29-2010

[eluser]parham90[/eluser]
Hello,

I have downloaded a library called Template library for CodeIgniter. While it is very good, I want to define a default menu bar for my whole application in the configuration. There's a problem with this, however. The items in the configuration file, apparently, do not get parsed. So if I put PHP code in the configuration file, it will just stay as is, and appear in the final HTML page. I am assuming what I need to do is to find something that runs every time a page is requested, and set the menu there. For example:
Code:
$data['menu') = "<ul>
<li>&lt;?=anchor('users/register', 'register')?&gt;</li>
</ul>
";

Is there a more clean workaround? If not, where do you recommend I put this code?

Thanks!


Using PHP code in the Template library configuration file? - El Forum - 07-29-2010

[eluser]gyo[/eluser]
This is a perfect situation to extend the main Controller using MY_Controller.

Enjoy!


Using PHP code in the Template library configuration file? - El Forum - 07-29-2010

[eluser]danmontgomery[/eluser]
Code:
$data['menu'] = "<ul>
<li>".anchor('users/register', 'register')."</li>
</ul>
";



Using PHP code in the Template library configuration file? - El Forum - 07-29-2010

[eluser]parham90[/eluser]
Hi!

Thanks! I thought even though I am autoloading 'url', it won't get loaded when the configuration files are read. *smiles*

[quote author="noctrum" date="1280444493"]
Code:
$data['menu'] = "<ul>
<li>".anchor('users/register', 'register')."</li>
</ul>
";
[/quote]