Permalink in variable

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Cel
Regular
Posts: 17
Joined: Sat Jan 26, 2008 12:46 am

Permalink in variable

Post by Cel »

Hi,

I need to construct the permalink of an entry with smarty or php. I would like to use it to dynamically generate buttons for social bookmarking of an entry. As far as I can tell there is not a smarty variable holding the permalink. What would be the simplest way to get it ?

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

Re: Permalink in variable

Post by garvinhicking »

Hi!

The permalink of an entry is stored in {$entry.rdf_ident}!

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/
Cel
Regular
Posts: 17
Joined: Sat Jan 26, 2008 12:46 am

Post by Cel »

Hi Garvin,

I was hoping it would be something simple like this. However, this variable seems to be not available in the entry itself (i.e. the body text).

The documentation says it is just available in entries.tpl. I would like to decide on a case by case basis whether to include the social bookmarking buttons or not. (for some of my entries they don't make sense).

I guess I need a variable that is available in *.tpl ? Or alternatively, can I define a variable in the entry body text and then use that variable in entries.tpl to decide if it should display the buttons or not ?

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

Post by garvinhicking »

Hi!
I was hoping it would be something simple like this. However, this variable seems to be not available in the entry itself (i.e. the body text).
What do you mean? The variable is available inside the entries.tpl template. Where exactly do you want it?

Are you talking about the smarty markup plugin?

The variable is only available in the context of an entry, it doesn't make any sense in index.tpl (even though you can address it by looping through $entries)

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/
Cel
Regular
Posts: 17
Joined: Sat Jan 26, 2008 12:46 am

Post by Cel »

Hi,

What I mean is that I need the variable for code that I want to put in the entry body text. (Which then would be parsed by smarty markup plugin).

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

Post by garvinhicking »

Hi!

Okay, that is more complex then.

Are you really sure you need to do that with smarty markup WITHIN an entry, instead of editing the entries.tpl template and using custom entryproperties to indicate if you need the output?

The reason is, it gets hard to do that with smartymarkup. When the plugin is executed, it did not get any variables of its own entry. For that I patched the plugin in version 1.7 so that {$smartymarkup_eventData} gets passed to the smarty template of your entry body. So you need to fetch that plugin version from CVS / Spartacus.

So now you can acces {$smartymarkup_eventData.id} for the entryid.

Howver, rdf_ident will not be available then. You will need to build that with your own custom smarty function.

To do so, you need to edit your template's config.inc.php file and register yuor own smarty modifier:

Code: Select all

function serendipity_smarty_archiveURL($id, $title, $timestamp) {
    return serendipity_archiveURL($id, $title, 'baseURL', true, array('timestamp' => $timestamp));
}
$serendipity['smarty']->register_modifier('serendipity_smarty_archiveURL', 'serendipity_smarty_archiveURL');
Once you have done so, you can use this smarty markup in your entry:

Code: Select all

My Full Permalink is: {$smartymarkup_eventData.id|serendipity_smarty_archiveURL:$smartymarkup_eventData.title:$smartymarkup_eventData.timestamp}
Now you can pass that variable arround, maybe you even need to use {capture} or {assign} around it, depending on what you need the permalink for.

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/
Cel
Regular
Posts: 17
Joined: Sat Jan 26, 2008 12:46 am

Post by Cel »

Hi,

[quote]Are you really sure you need to do that with smarty markup WITHIN an entry, instead of editing the entries.tpl template and using custom entryproperties to indicate if you need the output?[/quote]

This is the alternative method I was looking for. From the documentation of custom entryproperties It was not clear to me that I could use that for any purpose.

I will try this route first. Thanks.

Regards,
Cel
Post Reply