Welcome Guest, Not a member yet? Register   Sign In
Printing out object properties or array values in CI's Template class
#1

[eluser]BrianDHall[/eluser]
OK, so I want to do the following in a view using the template class:

Code:
<p>Listing Address: {listing->address}</p>

I notice this, of course, does not work. Accessing an array element using the template class also doesn't work.

Is anyone aware of a good upgrade to CI's template class I can drop in (not Smarty, just something slick and relatively thin) that allows even such extremely minor sorts of features?

I know I can pre-load the variables I feed to the view and I suppose this is what I'll do, but it just seemed like it would be so nice to just do something like the above Sad
#2

[eluser]theprodigy[/eluser]
I'm not really knowledgable in using CI's template class, but what happens if you assign an array to a template variable, and then output the variable? Does the template class allow straight PHP? Is there an equivalent of print_r in the templating class (to see what it gets set as)?
#3

[eluser]Ben Edmunds[/eluser]
Phil Sturgeon integrated Dwoo nicely with CI. It's similar to smarty but lighter.
#4

[eluser]Jamie Rumbelow[/eluser]
[quote author="Ben Edmunds" date="1260506653"]Phil Sturgeon integrated Dwoo nicely with CI. It's similar to smarty but lighter.[/quote]

...and sexier.
#5

[eluser]BrianDHall[/eluser]
Dudes, Phil Sturgeon's implementation of Dwoo is sooo sexy!

It works just like I wanted!

Code:
controller:

$array['messages'][] = array('text' => 'hello');
$array['messages'][] = array('text' => ' ');
$array['messages'][] = array('text' => 'world');
$array['messages'][] = array('text' => '!');

view:

I would just like to say, {loop $messages}&lt;?php echo $text; ?&gt;{/loop}

And it actually works - you can mix PHP code right inside a set of Dwoo {loop} tags, no muss, no fuss.

I never thought I'd say it, but a templating engine is actually awesome, specifically as implemented by Phil in CI = Dwoo is the shiznit, and its impact on baseline performance seems altogether tolerable Smile




Theme © iAndrew 2016 - Forum software by © MyBB