[geeklog-cvs] geeklog: Document where CUSTOM_templateSetVars is actually calle...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Apr 26 06:14:22 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/cbedc66a434c
changeset: 6990:cbedc66a434c
user: Dirk Haun <dirk at haun-online.de>
date: Sun Apr 26 12:14:06 2009 +0200
description:
Document where CUSTOM_templateSetVars is actually called from (bug #0000862)
diffstat:
3 files changed, 41 insertions(+), 10 deletions(-)
public_html/docs/history | 2 ++
system/lib-custom.php.dist | 39 +++++++++++++++++++++++++++++++++------
system/lib-plugins.php | 10 ++++++----
diffs (86 lines):
diff -r ef93e28c7bca -r cbedc66a434c public_html/docs/history
--- a/public_html/docs/history Sun Apr 26 11:57:49 2009 +0200
+++ b/public_html/docs/history Sun Apr 26 12:14:06 2009 +0200
@@ -11,6 +11,8 @@
+ Comment moderation and editable comments, by Jared Wenerd
Other changes:
+- Document where CUSTOM_templateSetVars is actually called from (bug #0000862)
+ [Dirk]
- Added option to search by titles only (feature request #0000840) [Sami]
- Added a config option to enable/disable automatically turning URLs in text
postings into clickable URLs [Dirk]
diff -r ef93e28c7bca -r cbedc66a434c system/lib-custom.php.dist
--- a/system/lib-custom.php.dist Sun Apr 26 11:57:49 2009 +0200
+++ b/system/lib-custom.php.dist Sun Apr 26 12:14:06 2009 +0200
@@ -113,14 +113,41 @@
/**
* Include any code in this function to add custom template variables.
-* Initially, this function is only called in the COM_siteHeader function to set
-* header.thtml variables
+*
+* Called from within Geeklog for:
+* - 'header' (site header)
+* - 'footer' (site footer)
+* - 'storytext', 'featuredstorytext', 'archivestorytext' (story templates)
+* - 'story' (story submission)
+* - 'comment' (comments)
+* - 'registration' (user registration form)
+* - 'contact' (email user form)
+* - 'emailstory' (email story to a friend)
+*
+* This function is called whenever PLG_templateSetVars is called, i.e. in
+* addition to the templates listed here, it may also be called from plugins.
+*
+* @param string $templatename name of the template, e.g. 'header'
+* @param ref &$template reference to the template
+* @return void
+* @see PLG_templateSetVars
+*
*/
-function CUSTOM_templateSetVars ($templatename, &$template)
+function CUSTOM_templateSetVars($templatename, &$template)
{
- if ($templatename == 'header') {
- // define a {hello_world} variable which displays "Hello, world!"
- $template->set_var ('hello_world', 'Hello, world!');
+ // define a {hello_world} variable available in header.thtml and
+ // a {hello_again} variable available in the story templates
+
+ switch ($templatename) {
+ case 'header':
+ $template->set_var('hello_world', 'Hello, world!');
+ break;
+
+ case 'storytext':
+ case 'featuredstorytext':
+ case 'archivestorytext':
+ $template->set_var('hello_again', 'Hello (again)!');
+ break;
}
}
diff -r ef93e28c7bca -r cbedc66a434c system/lib-plugins.php
--- a/system/lib-plugins.php Sun Apr 26 11:57:49 2009 +0200
+++ b/system/lib-plugins.php Sun Apr 26 12:14:06 2009 +0200
@@ -1434,13 +1434,15 @@
/**
* This function can be called to check if an plugin wants to set a template
* variable
+*
* Example in COM_siteHeader, the API call is now added
-* A plugin can now check for templatename == 'header' and then set additional
+* A plugin can check for $templatename == 'header' and then set additional
* template variables
*
-* @param string $templatename Name of calling template - used as test in plugin function
-* @param ref $template reference for the Template
-* @return void
+* @param string $templatename Name of calling template
+* @param ref &$template reference for the Template
+* @return void
+* @see CUSTOM_templateSetVars
*
*/
function PLG_templateSetVars($templatename, &$template)
More information about the geeklog-cvs
mailing list