I need to access the entry tags in template

Creating and modifying plugins.
Post Reply
Fencer
Regular
Posts: 28
Joined: Fri Aug 11, 2006 9:26 am
Contact:

I need to access the entry tags in template

Post by Fencer »

Hello,
is there a way to get a list of tags defined for the particular entry, preferrably as a variable at the template?

Thank you.
Filip
http://BrainKing.com - play 80+ popular board games for free, 30,000+ registered users
http://BrainKing.info - the official blog of the BrainKing game site
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I need to access the entry tags in template

Post by garvinhicking »

Hi!

You mean you want to see all available variables for {$entry}? Like $entry.title, $entry.body etc.?

http://www.s9y.org/102.html should be what you need.

Else you could set $serendipity['security'] = false in your templates config.inc.php and use <pre>{$entry|@print_r}</pre>.

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/
Fencer
Regular
Posts: 28
Joined: Fri Aug 11, 2006 9:26 am
Contact:

Re: I need to access the entry tags in template

Post by Fencer »

Thank you Garvin but I am afraid it is not there (or I am blind). What I need is a variable/property containing all tags for the selected entry, defined through the "Tagging of entries" plugin. Is it possible to get this information at the entries.tpl?

Filip
garvinhicking wrote:Hi!

You mean you want to see all available variables for {$entry}? Like $entry.title, $entry.body etc.?

http://www.s9y.org/102.html should be what you need.

Else you could set $serendipity['security'] = false in your templates config.inc.php and use <pre>{$entry|@print_r}</pre>.

HTH,
Garvin
http://BrainKing.com - play 80+ popular board games for free, 30,000+ registered users
http://BrainKing.info - the official blog of the BrainKing game site
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I need to access the entry tags in template

Post by garvinhicking »

Hi!

Ah. This one should be inside the $entry.properties array somewhere. Make that print_r trick, and you should spot it instantly.

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/
Fencer
Regular
Posts: 28
Joined: Fri Aug 11, 2006 9:26 am
Contact:

Re: I need to access the entry tags in template

Post by Fencer »

I've created a config.inc.php file in the /templates/contest directory (the template which I use) and put the $serendipity['security'] = false line to it. However, when I try to add <pre>{$entry|@print_r}</pre> at the end of the entries.tpl and reload the entry page, I receive this error message:

Fatal error: Smarty error: [in file:/var/www/brainking.info/web/templates/contest/entries.tpl line 250]: [plugin] (secure mode) modifier 'print_r' is not allowed (Smarty_Compiler.class.php, line 1908) in /data/www/brainking.info/web/bundled-libs/Smarty/libs/Smarty.class.php on line 1088

Is there anything else I have to do?

Filip
garvinhicking wrote:Hi!

Ah. This one should be inside the $entry.properties array somewhere. Make that print_r trick, and you should spot it instantly.

HTH,
Garvin
http://BrainKing.com - play 80+ popular board games for free, 30,000+ registered users
http://BrainKing.info - the official blog of the BrainKing game site
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I need to access the entry tags in template

Post by garvinhicking »

Hi!

Sorry, wrong variable. Needs to read

$serendipity['smarty']->security = false;

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/
Fencer
Regular
Posts: 28
Joined: Fri Aug 11, 2006 9:26 am
Contact:

Re: I need to access the entry tags in template

Post by Fencer »

garvinhicking wrote:Hi!

Sorry, wrong variable. Needs to read

$serendipity['smarty']->security = false;

Regards,
Garvin
I've tried this and it works. Thank you.
However, the entry tags have appeared only as a part of the $entry.body property (because that's where I set them to show up) but not at a standalone property. So unless there is another way, I would have to parse the body property and get the entry tags out of it.

Filip
http://BrainKing.com - play 80+ popular board games for free, 30,000+ registered users
http://BrainKing.info - the official blog of the BrainKing game site
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I need to access the entry tags in template

Post by garvinhicking »

Hi!

That shouldn't be - which version of the freetag plugin are you using?

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/
Fencer
Regular
Posts: 28
Joined: Fri Aug 11, 2006 9:26 am
Contact:

Re: I need to access the entry tags in template

Post by Fencer »

garvinhicking wrote:Hi!

That shouldn't be - which version of the freetag plugin are you using?

Regards,
Garvin
Tagging of entries
Allows freestyle tagging of entries
version: 2.63
http://BrainKing.com - play 80+ popular board games for free, 30,000+ registered users
http://BrainKing.info - the official blog of the BrainKing game site
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I need to access the entry tags in template

Post by garvinhicking »

Hi!

Du you have the plugin "Extended properties for entries" installed? Which serendipity version do you use?

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/
Fencer
Regular
Posts: 28
Joined: Fri Aug 11, 2006 9:26 am
Contact:

Re: I need to access the entry tags in template

Post by Fencer »

garvinhicking wrote:Hi!

Du you have the plugin "Extended properties for entries" installed? Which serendipity version do you use?

Regards,
Garvin
Extended properties for entries
(cache, non-public articles, sticky posts)
version: 1.8

I guess my Serendipity version is 1.0 because I've found this line at the serendipity_config.inc.php:

// The version string
$serendipity['version'] = '1.0';

By the way, is there a way how to find the Serendipity version on the Admin page?

Filip
http://BrainKing.com - play 80+ popular board games for free, 30,000+ registered users
http://BrainKing.info - the official blog of the BrainKing game site
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I need to access the entry tags in template

Post by garvinhicking »

Hi!

Okay, if you have that plugin installed and are using s9y 1.0, then all should be well.

What is the output of {$entry.properties|@print:r} if you put that in the foreach loop of your entries.tpl file?

The s9y version should be printed in the footer of the admin section!

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/
Fencer
Regular
Posts: 28
Joined: Fri Aug 11, 2006 9:26 am
Contact:

Re: I need to access the entry tags in template

Post by Fencer »

garvinhicking wrote:Hi!

Okay, if you have that plugin installed and are using s9y 1.0, then all should be well.

What is the output of {$entry.properties|@print:r} if you put that in the foreach loop of your entries.tpl file?

The s9y version should be printed in the footer of the admin section!

HTH,
Garvin
I use your "contest" style which contains a custom admin interface, could it be the reason why I don't see the s9y version at the footer of the admin section?
Before I put the {$entry.properties|@print:r} in the foreach loop, is there a way how to show this debug info only for the admin? I don't want to display my experiments to everyone who observes the blog.

Filip
http://BrainKing.com - play 80+ popular board games for free, 30,000+ registered users
http://BrainKing.info - the official blog of the BrainKing game site
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: I need to access the entry tags in template

Post by garvinhicking »

Hi!

Hm, I currently don't have a testblog to check that, but I am quite sure that my contest theme does show the version info...

About only showing for admin: Yes, you can use a check to see if a user is logged in. Check www.s9y.org, technical documentation for a list of all variables that you can use, I don't know it by heart. :)

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/
Fencer
Regular
Posts: 28
Joined: Fri Aug 11, 2006 9:26 am
Contact:

Post by Fencer »

All right, I've finally got something. This is an excerpt of the print_r output:

Code: Select all

[properties] => Array
        (
            [freetag_tags] => Array
                (
                    [0] => javascript
                    [1] => messages
                    [2] => settings
                )

            [freetag_tagList] => javascript,messages,settings
        )
However, the problem is that it is shown only when the main blog page (containing more entries at once) is displayed. When I go to the single entry page (which is exactly where I need to use the entry tags property), the [properties] array is empty.

Is there a solution of this issue?

Filip
http://BrainKing.com - play 80+ popular board games for free, 30,000+ registered users
http://BrainKing.info - the official blog of the BrainKing game site
Post Reply