Accessing s9y variables in Smarty

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Thomas
Regular
Posts: 130
Joined: Tue Sep 21, 2004 2:00 pm
Location: Stockerau/NÖ/A
Contact:

Accessing s9y variables in Smarty

Post by Thomas »

Hi,

maybe I'm out of practise and this is just a stupid question but I need to know this.
I try to insert a banner display method into my blog and therefore I need to know how to access s9y's variables within Smarty. I know that usually in a PHP script I can access them with $serendipity['serendipityPath'] or $serendipity['fetchLimit']. According to Smarty's documentation I could use $serendipity.fetchLimit for associative variables. But nothing is displayed.

Another issue is the access for those variables within Smarty plugins. My plan is to write a Smarty function for displaying banners and therefore I need path names, for example. I could use hardcoded paths, but this would be amazing bad programming style. :)

Any hints or tips?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Accessing s9y variables in Smarty

Post by garvinhicking »

Actually, because of performance reasons, not all $serendipity values are assigned to Smarty. See include/functions_smarty.inc.php in the smarty_init() function call.

If you want to assign more or all of Serendipity's values to your template, create a "config.inc.php" file in your template directory:

Code: Select all

<?php
$serendipity['smarty']->assign('s9y', $serendipity);
?>
Best 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