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?
$CONTENT, $ENTRIES, $ARCHIVES
-
carl_galloway
- Regular
- Posts: 1331
- Joined: Sun Dec 04, 2005 5:43 pm
- Location: Andalucia, Spain
- Contact:
-
biancospino
- Regular
- Posts: 6
- Joined: Sat Sep 02, 2006 12:12 pm
- Contact:
Re: $CONTENT, $ENTRIES, $ARCHIVES
Checking Serendipity code it seems these Smarty variables are fetched through the relative template files (*.tpl) and then assigned again to Smarty.carl_galloway wrote:Can anyone tell me how these variables $CONTENT, $ENTRIES, $ARCHIVES are created?
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"
I don't knowcarl_galloway wrote: Can I create new uppercase variables that link to my own smarty files?
ciao
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: $CONTENT, $ENTRIES, $ARCHIVES
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:
to achieve fetching a file like that. Having smarty security turned on, you would first need to wrap that function:
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
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}
Code: Select all
$serendipity['smarty']->register_modifier('serendipity_smarty_fetch', 'serendipity_smarty_fetch');
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/
# 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: