Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
print out value of assign from plugin before plugin is calld

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


Joined: 11 May 2010
Posts: 14

PostPosted: Mon Apr 23, 2012 3:27 pm    Post subject: print out value of assign from plugin before plugin is calld Reply with quote

Hi,

I am trying to develop an advertising system around smarty. So i came up with a plugin which when spitted out on the page looks like this:

Code:
{load_ad id=c4ca4238a0b923820dcc509a6f75849b}


The trouble is that inside that function i have a variabled that is assigned called AD_HEAD.

Now AD_HEAD is suppose to show up above the </head> tag.

So a basic html will look like this:

Code:

<html>
<head>
{$AD_HEAD}
</head>
<body>
{load_ad id=c4ca4238a0b923820dcc509a6f75849b}
</body>
</html>


As you can see AD_HEAD is placed higher then load_ad.

Trouble is since it is placed higher it will remain empty but when i put it lower then load_ad it will work.

How can i get this to work, or will i need to develop this differently?
Back to top
View user's profile Send private message
douglassdavis
Smarty Junkie


Joined: 21 Jan 2008
Posts: 538

PostPosted: Mon Apr 23, 2012 3:59 pm    Post subject: Re: print out value of assign from plugin before plugin is c Reply with quote

Dice wrote:
Hi,

I am trying to develop an advertising system around smarty. So i came up with a plugin which when spitted out on the page looks like this:

Code:
{load_ad id=c4ca4238a0b923820dcc509a6f75849b}


The trouble is that inside that function i have a variabled that is assigned called AD_HEAD.

Now AD_HEAD is suppose to show up above the </head> tag.

So a basic html will look like this:

Code:

<html>
<head>
{$AD_HEAD}
</head>
<body>
{load_ad id=c4ca4238a0b923820dcc509a6f75849b}
</body>
</html>


As you can see AD_HEAD is placed higher then load_ad.

Trouble is since it is placed higher it will remain empty but when i put it lower then load_ad it will work.

How can i get this to work, or will i need to develop this differently?


many ways, one is to do something like this:

{load_ad id=c4ca4238a0b923820dcc509a6f75849b assign_body='AD_BODY' assign_head='AD_HEAD'}

Give the plugin variable names to put the head and body. Put that right at the top of the page, then using the vars you can display the head and body wherever you need to. Or, less desirable from a software design standpoint is to make it automatically assign to AD_HEAD and AD_BODY without being given the variable names.
Back to top
View user's profile Send private message
Dice
Smarty Rookie


Joined: 11 May 2010
Posts: 14

PostPosted: Mon Apr 23, 2012 4:18 pm    Post subject: Re: print out value of assign from plugin before plugin is c Reply with quote

douglassdavis wrote:
Dice wrote:
Hi,

I am trying to develop an advertising system around smarty. So i came up with a plugin which when spitted out on the page looks like this:

Code:
{load_ad id=c4ca4238a0b923820dcc509a6f75849b}


The trouble is that inside that function i have a variabled that is assigned called AD_HEAD.

Now AD_HEAD is suppose to show up above the </head> tag.

So a basic html will look like this:

Code:

<html>
<head>
{$AD_HEAD}
</head>
<body>
{load_ad id=c4ca4238a0b923820dcc509a6f75849b}
</body>
</html>


As you can see AD_HEAD is placed higher then load_ad.

Trouble is since it is placed higher it will remain empty but when i put it lower then load_ad it will work.

How can i get this to work, or will i need to develop this differently?


many ways, one is to do something like this:

{load_ad id=c4ca4238a0b923820dcc509a6f75849b assign_body='AD_BODY' assign_head='AD_HEAD'}

Give the plugin variable names to put the head and body. Put that right at the top of the page, then using the vars you can display the head and body wherever you need to. Or, less desirable from a software design standpoint is to make it automatically assign to AD_HEAD and AD_BODY without being given the variable names.
Trouble is i only want to write it in once. Which is the load_ad function since there will be multiple ads no the page and if the ad has header code it gets appended to ad_head.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins 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