Problems using Smarty code in entries (custom fields)

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
dakotaroar
Regular
Posts: 21
Joined: Thu Nov 08, 2007 3:30 pm

Problems using Smarty code in entries (custom fields)

Post 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?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Problems using Smarty code in entries (custom fields)

Post 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:

Code: Select all

{my_smarty_func var1=$var2}
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
# 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/
dakotaroar
Regular
Posts: 21
Joined: Thu Nov 08, 2007 3:30 pm

Post 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?
dakotaroar
Regular
Posts: 21
Joined: Thu Nov 08, 2007 3:30 pm

Post 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.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# 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/
dakotaroar
Regular
Posts: 21
Joined: Thu Nov 08, 2007 3:30 pm

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# 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/
Post Reply