CI helpers in EE templates |
[eluser]e-man[/eluser]
I've only just began to get my feet wet with CI and was wondering: if I have CI installed as well as EE can I use the CI helpers inside the EE templates? In other words, can I just do: Code: $this->load->helper('name');
[eluser]Jamie Rumbelow[/eluser]
No. As of yet, EE and CI aren't linked. When EE 2.0 comes however, I'm going to assume there will be a EE tag such as this: Code: {exp:codeigniter:helper="name"}
[eluser]e-man[/eluser]
Would be cool, those helpers contain a lot of cool functionality I'll keep my eyes peeled!
[eluser]Derek Allard[/eluser]
Hey e-man. Welcome to CI, the dark-underbelly of EllisLab You could enable PHP in a template and then explicitly include the helper file you want. I know you were looking for something a bit more automagic, but as of right now, that's how it'd need to be done.
[eluser]e-man[/eluser]
That completely slipped my mind... so a simple Code: include '/path/to/helpername.php';
[eluser]Tom Glover[/eluser]
Yes the call the function by name with out $this-> or $this->helper->...
[eluser]Derek Allard[/eluser]
Well, you don't use $this->helper with helpers anyhow, but you're right wackywebs if we were trying to use libraries it would take a little more playing. The only thing I can think of offhand is that each helper has Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); at the top, which will prevent the file from loading. This is easily worked around by just defining that constant. Here's an example Enable php in a template (on output). Put the "helpers" library into your root directory. Code: <?php
[eluser]e-man[/eluser]
Can't believe you snuck in a reference to Eminem's granddad in there Derek, truly evil Jest aside, thanks for the info, I'll have a play with it...
[eluser]Derek Allard[/eluser]
[quote author="e-man" date="1213415123"]Can't believe you snuck in a refefrence to Eminem's granddad in there Derek, truly evil [/quote] Dude, that's nothing. I've been much, much, much worse in the past |
Welcome Guest, Not a member yet? Register Sign In |