Welcome Guest, Not a member yet? Register   Sign In
how integrate smarty with codeigniter
#1

[eluser]Ehsan-ul-haq[/eluser]
hi

i would like to integrate smarty with codeigniter ,


any one please help me to to do this....
#2

[eluser]Thorpe Obazee[/eluser]
quick search:

http://ellislab.com/forums/viewthread/60050

http://devcha.blogspot.com/2007/12/smart...-code.html
#3

[eluser]Dam1an[/eluser]
Bargainph,you forgot the most important link of all, lmgtfy Wink
#4

[eluser]Thorpe Obazee[/eluser]
[quote author="Dam1an" date="1244637864"]Bargainph,you forgot the most important link of all, lmgtfy Wink[/quote]

Yeah, forgot about that Tongue
#5

[eluser]Phil Sturgeon[/eluser]
Here's a quick guide on how to "Access CodeIgniter helpers from Smarty templates". Use this once you have Smarty up and running.
#6

[eluser]the5threvolution[/eluser]
[quote author="Phil Sturgeon" date="1244641695"]Here's a quick guide on how to "Access CodeIgniter helpers from Smarty templates. Use this once you have Smarty up and running.[/quote]

His code is extremely useful.

Couple of corrections though.

1. File name is modifier.helper.php not helper.modifier.php
2. Directory you should put this file is plugins under smarty library, not directly under CI plugins folder.
3. You need to add unset($params[2]); before return.

So in smarty, (from the example from the link..)
{$item.url|helper:'url':'anchor':$item.title:'class="more params"'}
$item.url is the first parameter of the helper function
$item.title is the second parameter of the helper function
and anything after that pretty much follows.
In this case, it's like anchor($item.url, $item.title, 'class="more params"');
Those variables can be assigned from php, or hard coded in tpl file, up to you.

Thank you Phil Sturgeon!
#7

[eluser]Phil Sturgeon[/eluser]
I have never tested this code but a few people told me it worked fine so just went ahead and posted it up. Lazy I know :-$

I agree with all your points but not sure why I would need to unset $params[2]. That would be the 3rd argument which would work out as the first actual parameter. In this example, unset $params[2] would wipe off $item.title!
#8

[eluser]the5threvolution[/eluser]
[quote author="Phil Sturgeon" date="1247757761"]I have never tested this code but a few people told me it worked fine so just went ahead and posted it up. Lazy I know :-$

I agree with all your points but not sure why I would need to unset $params[2]. That would be the 3rd argument which would work out as the first actual parameter. In this example, unset $params[2] would wipe off $item.title![/quote]

Hello,

When I ran it and echoed all the parameters passed; print_array($params) before $params[0] = $string;,

from the example {$item.url|helper:‘url’:‘anchor’:$item.title:‘class=“more params”’},

$params[0] = $item.url
$params[1] = 'url'
$params[2] = 'anchor'
$params[3] = $item.title
$params[4] = 'class="more params"'

So, without unset $params[2], all the parameters were shifted and the example gave the output as: "Check out this amazing item
Code:
<em><a href="http://localhost/contact/index.php/test">anchor</a></em>
...
(I cannot add code properly, but it's like ..."index.php/test" this is the title> ...)

Here's the output and test code:
Code:
print_r($params);
echo "<br><br><br>";
$params[0] = $string;
unset($params[1]);
print_r($params);
echo "<br><br><br>";
unset($params[2]);
print_r($params);
echo "<br><br><br>";

Output was... ($item.url was "test" and $item.title was "this is the title")
Array ( [0] => test [1] => url [2] => anchor [3] => this is the title [4] => class="more params" )
Array ( [0] => test [2] => anchor [3] => this is the title [4] => class="more params" )
Array ( [0] => test [3] => this is the title [4] => class="more params" )

I wonder if different smarty version makes a difference? I think I have the latest smarty though..

Thank you~




Theme © iAndrew 2016 - Forum software by © MyBB