Page 1 of 1
Problems using Smarty code in entries (custom fields)
Posted: Mon Jan 21, 2008 8:10 pm
by dakotaroar
I can't seem to get my custom field data to show up in Smarty entries. I have it set up to parse Smarty within entries, and I have the extended properties cache turned off. So if I name a custom field "Test", and then try to call it with {$entry.properties.ep_Test}, it doesn't output anything.
Also, is there a way to nest Smarty functions? Say I have a function Test1($var1) and I have it set up as a Smarty function and I want to put the value from {Test2} into it. Is this possible?
Re: Problems using Smarty code in entries (custom fields)
Posted: Mon Jan 21, 2008 8:17 pm
by garvinhicking
Hi!
Where do you use the {$entry.properties.ep_Test} variable? Inside your entries.tpl file? There it should work!
Or do you mean by using the smarty markup plugin? There you need to use {$eventData.properties.ep_Test} I think. Try {$eventData|@print_r} to see which variables you have.
Also, is there a way to nest Smarty functions? Say I have a function Test1($var1) and I have it set up as a Smarty function and I want to put the value from {Test2} into it. Is this possible?
Can you be more specific? You can do this:
but you cannot do this:
Code: Select all
{my_smarty_func1 var1={my_smarty_func var1=$var2}}
For that, have a look at the {capture} command, or you need to use {php} tags.
Regards,
Garvin
Posted: Mon Jan 21, 2008 8:34 pm
by dakotaroar
{$eventData|@print_r} gives me '1' as an output.
Yes, I am trying to use the Smarty tags within the entry body, and I have installed the Smarty Markup Plugin and everything is turned on.
If I try putting {$entry.properties.ep_Test} in entries.tpl, it outputs '0' even when there is a value in the 'Test' custom field.
Thanks for the help on the Smarty functions, but where are 'var1' and '$var2' coming from?
Posted: Tue Jan 22, 2008 12:02 am
by dakotaroar
I've just tried this on a new install and it works in the sidebar but not in the post itself. I must have done something to my old install (not the theme, because it doesn't work in the default theme either) that is messing with the plugin in some way.
I'll look into it later tonight.
Posted: Tue Jan 22, 2008 11:54 am
by garvinhicking
Hi!
Which other event plugins are you using?
Try
{$GLOBALS|@print_r}
within the entry body to see all available variables, somewhere there should be the properties array...?
Regards,
Garvin
Posted: Tue Jan 22, 2008 3:32 pm
by dakotaroar
{$GLOBALS|@print_r} outputs "1" as well. I tried it on the fresh install and it doesn't work there either.
My event plugins are:
[C] Markup: Serendipity
[C] Markup: Emoticate
[C] Markup: NL2BR
Browser Compatibility
[C] Spam Protector
[C] Static Pages
[C] Show links to services like Digg, Technorati, del.icio.us etc related to your entry.
[C] Markup: Smarty Parsing
[C] Extended properties for entries
Posted: Tue Jan 22, 2008 4:17 pm
by garvinhicking
Hi!
Ah, it might be that I wrongly used the syntax, does {$GLOBALS|print_r} work?
In your usage case, it might be that you need to move the Smarty-markup parsing plugin after the entryproperties plugin in the order of plugins.
Regards,
Garvin