CodeIgniter Forums

Full Version: Using PHP code in the Template library configuration file?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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!

El Forum

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

Enjoy!

El Forum

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

El Forum

[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]