Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Dedicated server web hosting provided by Guru-host.eu.
Smarty 3 assign variable in template

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
fl3x7
Smarty Rookie


Joined: 12 Feb 2011
Posts: 8

PostPosted: Sun Apr 22, 2012 10:05 pm    Post subject: Smarty 3 assign variable in template Reply with quote

Hello,

Having a bit of a problem. Trying to assign a template variable within a smarty 3 template file but it doesnt seem to register it.

I know I can use this in the controller:

$this->data['myVar'] = 'something';

But dont want to use that. I have tried this:

{assign var="myVar" value="something" noache}

But for some reason it just doesnt seem to work.

The template this is being used in is extending another template.

I have tried setting the variable scope to global.

The other weird thing is even if i try and assign a variable which is then just being outputted just below (in the same template file), it still returns empty as if the assign method is not doing anything at all. No errors though.

I am using smarty in conjunction with code igniter if that helps Smile

Hope someone can shed some light,

Thanks for reading.
Back to top
View user's profile Send private message
fl3x7
Smarty Rookie


Joined: 12 Feb 2011
Posts: 8

PostPosted: Mon Apr 23, 2012 11:04 pm    Post subject: Reply with quote

I ended up just using {block}{/block} for this as I was extending templates anyway.

Hope this helps someone else.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP