$CONTENT, $ENTRIES, $ARCHIVES

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

$CONTENT, $ENTRIES, $ARCHIVES

Post by carl_galloway »

Can anyone tell me how these variables $CONTENT, $ENTRIES, $ARCHIVES are created?

Can I create new uppercase variables that link to my own smarty files?
biancospino
Regular
Posts: 6
Joined: Sat Sep 02, 2006 12:12 pm
Contact:

Re: $CONTENT, $ENTRIES, $ARCHIVES

Post by biancospino »

carl_galloway wrote:Can anyone tell me how these variables $CONTENT, $ENTRIES, $ARCHIVES are created?
Checking Serendipity code it seems these Smarty variables are fetched through the relative template files (*.tpl) and then assigned again to Smarty.
You can see them at:
- genpage.inc.php, line 101 for CONTENT
- functions_entries.inc.php, line 854 and 1440 for $ENTRIES, $ARCHIVES

Garvin...your code is great and well written, thank you for sharing... "German do it better" :)
carl_galloway wrote: Can I create new uppercase variables that link to my own smarty files?
I don't know :(

ciao
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: $CONTENT, $ENTRIES, $ARCHIVES

Post by garvinhicking »

Hi!

Uppercase variable names in our case, like binacospino pointed out, indicate that code is fetched from other files.

This is done through the use of serendipity_smarty_fetch(). It is used in our PHP code and tells that $CONTENT is the content of the file 'content.tpl'.

If you just place $MYFILE in your template file, then it will print an empty variable because smarty does not know where it should get the contents from. This means that you would need to write PHP code (through the use of a plugin or config.inc.php) that uses the assign() method or the serendipity_smarty_fetch() to associate a file with a variable.

If you turn smarty security off, you could use:

Code: Select all

{'MYVAR'|serendipity_smarty_fetch:'myfile.tpl'}
{$MYVAR}
to achieve fetching a file like that. Having smarty security turned on, you would first need to wrap that function:

Code: Select all

$serendipity['smarty']->register_modifier('serendipity_smarty_fetch', 'serendipity_smarty_fetch');
to use the same code like above. You could also create a wrapper smarty function, but that would be more trouble as different function arguments would be required.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

Ok, that answers my question nicely, so basically those variables just call the template file with the samer name, that means they aren't special at all. There is no additional parsing happening. So if I want to create my own smarty files I should just use the {include file} directive. Cool.
Post Reply