diff options
author | vdigital <vdigital@piwigo.org> | 2008-07-14 21:42:40 +0000 |
---|---|---|
committer | vdigital <vdigital@piwigo.org> | 2008-07-14 21:42:40 +0000 |
commit | df29ffbde72e88635f454d5d6d84c5a7209460f3 (patch) | |
tree | 0a35be2731fe75fe86e11adad6f0147f180956d8 | |
parent | b7709eae0dcb81df9eb668407b64f2cde38ba1f0 (diff) |
Feature template-extension based on 2006 chrisaga's idea.
chrisaga wrote: "If you want to make some template customization without building a brand new
template, you should use ..."
git-svn-id: http://piwigo.org/svn/trunk@2434 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | admin.php | 1 | ||||
-rw-r--r-- | admin/extend_for_templates.php | 213 | ||||
-rw-r--r-- | admin/template/yoga/admin.tpl | 1 | ||||
-rw-r--r-- | admin/template/yoga/admin/extend_for_templates.tpl | 34 | ||||
-rw-r--r-- | admin/template/yoga/theme/admin/themeconf.inc.php | 1 | ||||
-rw-r--r-- | include/template.class.php | 28 | ||||
-rw-r--r-- | install/db/72-database.php | 48 | ||||
-rw-r--r-- | language/en_UK/admin.lang.php | 8 | ||||
-rw-r--r-- | language/en_UK/help/extend_for_templates.html | 98 | ||||
-rw-r--r-- | language/fr_FR/admin.lang.php | 10 | ||||
-rw-r--r-- | language/fr_FR/help/extend_for_templates.html | 98 | ||||
-rw-r--r-- | template-extension/distributed/samples/my-picture.tpl | 35 | ||||
-rw-r--r-- | template-extension/distributed/samples/my-thumbnails.tpl | 36 | ||||
-rw-r--r-- | template-extension/distributed/samples/my-thumbnails2.tpl | 36 |
14 files changed, 643 insertions, 4 deletions
@@ -78,6 +78,7 @@ $template->assign( 'U_ADVANCED_FEATURE'=> $link_start.'advanced_feature', 'U_CONFIG_GENERAL'=> $link_start.'configuration', 'U_CONFIG_DISPLAY'=> $conf_link.'default', + 'U_CONFIG_EXTENTS'=> $link_start.'extend_for_templates', 'U_CATEGORIES'=> $link_start.'cat_list', 'U_MOVE'=> $link_start.'cat_move', 'U_CAT_OPTIONS'=> $link_start.'cat_options', diff --git a/admin/extend_for_templates.php b/admin/extend_for_templates.php new file mode 100644 index 000000000..c6319368a --- /dev/null +++ b/admin/extend_for_templates.php @@ -0,0 +1,213 @@ +<?php +// +-----------------------------------------------------------------------+ +// | Piwigo - a PHP based picture gallery | +// +-----------------------------------------------------------------------+ +// | Copyright(C) 2008 Piwigo Team http://piwigo.org | +// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | +// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | +// +-----------------------------------------------------------------------+ +// | This program is free software; you can redistribute it and/or modify | +// | it under the terms of the GNU General Public License as published by | +// | the Free Software Foundation | +// | | +// | This program is distributed in the hope that it will be useful, but | +// | WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | +// | General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software | +// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | +// | USA. | +// +-----------------------------------------------------------------------+ + +/** + * Define replacement conditions for each template from template-extension + * (template called "replacer"). + * + * "original template" from ./template/yoga (or any other than yoga) + * will be replaced by a "replacer" if the replacer is linked to this "original template" + * (and optionally, when the requested URL contains an "optional URL keyword"). + * + * "Optional URL keywords" are those you can find after the module name in URLs. + * + * Therefore "Optional URL keywords" can be an active "permalink" + * (see permalinks in our documentation for further explanation). + */ + +// +-----------------------------------------------------------------------+ +// | functions | +// +-----------------------------------------------------------------------+ + +/** + * returns a list of templates currently available in template-extension + * + * Each .tpl file is extracted from template-extension. + * + * @return array + */ +function get_extents($start='') +{ + if ($start == '') { $start = './template-extension'; } + $dir = opendir($start); + $extents = array(); + + while (($file = readdir($dir)) !== false) + { + if ( $file == '.' or $file == '..' or $file == '.svn') continue; + $path = $start . '/' . $file; + if (is_dir($path)) + { + $extents = array_merge($extents, get_extents($path)); + } + elseif ( !is_link($path) and file_exists($path) + and strripos($path,'.tpl') > 0 ) + { + $extents[] = substr($path, 21); + } + } + return $extents; +} +// +-----------------------------------------------------------------------+ +// initialization | +// +-----------------------------------------------------------------------+ + +if (!defined('PHPWG_ROOT_PATH')) { die('Hacking attempt!'); } +include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); +check_status(ACCESS_ADMINISTRATOR); + +$tpl_extension = isset($conf['extents_for_templates']) ? + unserialize($conf['extents_for_templates']) : array(); +$new_extensions = get_extents(); + +/* Selective URLs keyword */ +$relevant_parameters = array( + '----------', + 'category', + 'favorites', + 'most_visited', + 'best_rated', + 'recent_pics', + 'recent_cats', + 'created-monthly-calendar', + 'posted-monthly-calendar', + 'search', + 'flat', + 'list',); /* <=> Random */ + $query = ' +SELECT permalink + FROM '.CATEGORIES_TABLE.' + WHERE permalink IS NOT NULL +'; + +/* Add active permalinks */ +$permalinks = array_from_query($query, 'permalink'); +$relevant_parameters = array_merge($relevant_parameters, $permalinks); + +/* Link all supported templates to their respective handle */ +$eligible_templates = array( + '----------' => 'N/A', + 'about.tpl' => 'about', + 'identification.tpl' => 'identification', + 'mainpage_categories.tpl' => 'index_category', + 'thumbnails.tpl' => 'index_thumbnails', + 'redirect.tpl' => 'redirect', + 'menubar.tpl' => 'menubar', + 'header.tpl' => 'header', + 'footer.tpl' => 'tail', + 'index.tpl' => 'index', + 'nbm.tpl' => 'nbm', + 'notification.tpl' => 'notification', + 'picture_content.tpl' => 'default_content', + 'slideshow.tpl' => 'picture', /* => slideshow is missing */ + 'picture.tpl' => 'picture', + 'popuphelp.tpl' => 'popuphelp', + 'profile.tpl' => 'profile', + 'profile_content.tpl' => 'profile_content', + 'register.tpl' => 'register', + 'search.tpl' => 'search', + 'search_rules.tpl' => 'search_rules', + 'tags.tpl' => 'tags', + 'upload.tpl' => 'upload',); + $flip_templates = array_flip($eligible_templates); +// +-----------------------------------------------------------------------+ +// | selected templates | +// +-----------------------------------------------------------------------+ + +if (isset($_POST['submit']) and !is_adviser()) +{ + $replacements = array(); + $i = 0; + while (isset($_POST['reptpl'][$i])) + { + $newtpl = $_POST['reptpl'][$i]; + $original = $_POST['original'][$i]; + $handle = $eligible_templates[$original]; + $url_keyword = $_POST['url'][$i]; + if ($url_keyword == '----------') $url_keyword = 'N/A'; + if ($handle != 'N/A') + { + $replacements[$newtpl] = array($handle, $url_keyword); + } + $i++; + } + $conf['extents_for_templates'] = serialize($replacements); + $tpl_extension = $replacements; + /* ecrire la nouvelle conf */ + $query = " +UPDATE ".CONFIG_TABLE." + SET value = '". $conf['extents_for_templates'] ."' +WHERE param = 'extents_for_templates';"; + if (pwg_query($query)) + { + array_push($page['infos'], + l10n('Templates recorded.')); + } +} + +// +-----------------------------------------------------------------------+ +// | template init | +// +-----------------------------------------------------------------------+ + +/* Clearing (remove old extents, add new ones) */ +foreach ($tpl_extension as $file => $conditions) +{ + if ( !in_array($file,$new_extensions) ) unset($tpl_extension[$file]); + else $new_extensions = array_diff($new_extensions,array($file)); +} +foreach ($new_extensions as $file) +{ + $tpl_extension[$file] = array('N/A' => 'N/A'); +} + +$template->set_filenames(array('extend_for_templates' + => 'admin/extend_for_templates.tpl')); + +$base_url = PHPWG_ROOT_PATH.'admin.php?page=extend_for_templates'; + +$template->assign( + array( + 'U_HELP' => get_root_url().'popuphelp.php?page=extend_for_templates', + )); +ksort($tpl_extension); +foreach ($tpl_extension as $file => $conditions) +{ + $handle = $conditions[0]; + $url_keyword = $conditions[1]; + { + $template->append('extents', + array( + 'replacer' => $file, + 'url_parameter' => $relevant_parameters, + 'original_tpl' => array_keys($eligible_templates), + 'selected_tpl' => $flip_templates[$handle], + 'selected_url' => $url_keyword,) + ); + } +} +// +-----------------------------------------------------------------------+ +// | html code display | +// +-----------------------------------------------------------------------+ + +$template->assign_var_from_handle('ADMIN_CONTENT', 'extend_for_templates'); +?>
\ No newline at end of file diff --git a/admin/template/yoga/admin.tpl b/admin/template/yoga/admin.tpl index 1c5c13035..e0d44a17e 100644 --- a/admin/template/yoga/admin.tpl +++ b/admin/template/yoga/admin.tpl @@ -23,6 +23,7 @@ <ul> <li><a href="{$U_CONFIG_GENERAL}">{'conf_general'|@translate}</a></li> <li><a href="{$U_CONFIG_DISPLAY}">{'conf_display'|@translate}</a></li> + <li><a href="{$U_CONFIG_EXTENTS}">{'conf_extents'|@translate}</a></li> </ul> </dd> </dl> diff --git a/admin/template/yoga/admin/extend_for_templates.tpl b/admin/template/yoga/admin/extend_for_templates.tpl new file mode 100644 index 000000000..fdac49b7d --- /dev/null +++ b/admin/template/yoga/admin/extend_for_templates.tpl @@ -0,0 +1,34 @@ +{* $Id$ *} +<div class="titrePage"><h2>{'extend_for_templates'|@translate}</h2> +</div> +{if isset($extents)} +<h4>{'Replacement of original templates'|@translate}</h4> +<form method="post" name="extend_for_templates" id="extend_for_templates" action="{$F_ACTION}"> + <table class="table2"> + <tr class="throw"> + <th>{'Replacers'|@translate}</th> + <th>{'Original templates'|@translate}</th> + <th>{'Optional URL keyword'|@translate}</th> + </tr> + {foreach from=$extents item=tpl name=extent_loop} + <tr class="{if $smarty.foreach.extent_loop.index is odd}row1{else}row2{/if}"> + <td> + <input type="hidden" name=reptpl[] value="{$tpl.replacer}" /> + {$tpl.replacer} + </td> + <td> + {html_options name=original[] output=$tpl.original_tpl values=$tpl.original_tpl selected=$tpl.selected_tpl} + </td> + <td> + {html_options name=url[] output=$tpl.url_parameter values=$tpl.url_parameter selected=$tpl.selected_url} + </td> + </tr> + {/foreach} + </table> + {if !is_adviser()} + <p> + <input class="submit" type="submit" value="{'Submit'|@translate}" name="submit" /> + </p> + {/if} +</form> +{/if}
\ No newline at end of file diff --git a/admin/template/yoga/theme/admin/themeconf.inc.php b/admin/template/yoga/theme/admin/themeconf.inc.php index 9629b274f..e3b6fc63e 100644 --- a/admin/template/yoga/theme/admin/themeconf.inc.php +++ b/admin/template/yoga/theme/admin/themeconf.inc.php @@ -8,6 +8,7 @@ function selected_admin_menu() { switch ($_GET['page']) { case 'configuration': + case 'extend_for_templates': return 1; case 'site_manager': case 'site_update': diff --git a/include/template.class.php b/include/template.class.php index 1fd3c94ac..e7ab39b8d 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -145,22 +145,44 @@ class Template { */ function set_filenames($filename_array) { + global $conf; if (!is_array($filename_array)) { return false; } - reset($filename_array); + $tpl_extension = isset($conf['extents_for_templates']) ? + unserialize($conf['extents_for_templates']) : array(); while(list($handle, $filename) = each($filename_array)) { if (is_null($filename)) unset( $this->files[$handle] ); else - $this->files[$handle] = $filename; + { + if (!isset($this->files[$handle])) $this->files[$handle] = $filename; + foreach ($tpl_extension as $file => $conditions) + { + $localtpl = './template-extension/' . $file; + if ($handle == $conditions[0] and + (stripos(implode('/',array_flip($_GET)),$conditions[1])>0 + or $conditions[1] == 'N/A') + and file_exists($localtpl)) + { /* examples: Are best_rated, created-monthly-calendar, list, ... set? */ + $this->files[$handle] = '../.' . $localtpl; + /* assign their tpl-extension */ + /* For test purpose: Do advanced users need a php access? */ + // $localphp = '../.' . substr($localtpl,0,-3).'php'; + // if (file_exists($localphp)) @include_once($localphp); + } + } + } } return true; } - + function on_extension($key, $tlpname) + { + return $tplname; + } /** see smarty assign http://www.smarty.net/manual/en/api.assign.php */ function assign($tpl_var, $value = null) { diff --git a/install/db/72-database.php b/install/db/72-database.php new file mode 100644 index 000000000..d43c2f937 --- /dev/null +++ b/install/db/72-database.php @@ -0,0 +1,48 @@ +<?php +// +-----------------------------------------------------------------------+ +// | Piwigo - a PHP based picture gallery | +// +-----------------------------------------------------------------------+ +// | Copyright(C) 2008 Piwigo Team http://piwigo.org | +// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | +// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | +// +-----------------------------------------------------------------------+ +// | This program is free software; you can redistribute it and/or modify | +// | it under the terms of the GNU General Public License as published by | +// | the Free Software Foundation | +// | | +// | This program is distributed in the hope that it will be useful, but | +// | WITHOUT ANY WARRANTY; without even the implied warranty of | +// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | +// | General Public License for more details. | +// | | +// | You should have received a copy of the GNU General Public License | +// | along with this program; if not, write to the Free Software | +// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | +// | USA. | +// +-----------------------------------------------------------------------+ + +if (!defined('PHPWG_ROOT_PATH')) +{ + die('Hacking attempt!'); +} + +$upgrade_description = 'Add extents_for_templates config'; + +include_once(PHPWG_ROOT_PATH.'include/constants.php'); + +// +-----------------------------------------------------------------------+ +// | Upgrade content | +// +-----------------------------------------------------------------------+ + +$query = " +INSERT INTO ".CONFIG_TABLE." (param,value,comment) VALUES ('extents_for_templates','a:0:{}','Actived template-extension(s)'); +"; +pwg_query($query); + +echo +"\n" +.'"'.$upgrade_description.'"'.' ended' +."\n" +; + +?> diff --git a/language/en_UK/admin.lang.php b/language/en_UK/admin.lang.php index 6f73d4b8d..129623864 100644 --- a/language/en_UK/admin.lang.php +++ b/language/en_UK/admin.lang.php @@ -649,4 +649,12 @@ $lang['Deleted on'] = 'Deleted on'; $lang['Last hit'] = 'Last hit'; $lang['Hits'] = 'Hits'; $lang['GD library is missing'] = 'GD library is missing'; +$lang['conf_extents'] = 'Templates'; +$lang['extend_for_templates'] = 'Extend for templates'; +$lang['Replacement of original templates'] = + 'Replacement of original templates by customized templates from template-extension subfolder'; +$lang['Replacers'] = 'Replacers (customized templates)'; +$lang['Original templates'] = 'Original templates'; +$lang['Optional URL keyword'] = 'Optional URL keyword'; +$lang['Templates recorded.'] = 'Templates configuration has been recorded.'; ?> diff --git a/language/en_UK/help/extend_for_templates.html b/language/en_UK/help/extend_for_templates.html new file mode 100644 index 000000000..8e2c7ac6b --- /dev/null +++ b/language/en_UK/help/extend_for_templates.html @@ -0,0 +1,98 @@ +<h2>Extend for templates configuration</h2> + +<h3>Goal</h3> +<p>Define replacement conditions for each template from template-extension +(template called "replacer").</p> + +<p>"original template" from ./template/yoga (or any other than yoga) + will be replaced by a "replacer" if the replacer is linked to this "original template" + (and optionally, when the requested URL contains an "optional URL keyword").</p> + +<p>"Optional URL keywords" are those you can find after the module name in URLs.</p> + +<p>Therefore "Optional URL keywords" can be an active "permalink" +(see permalinks in our documentation for further explanation).</p> + +<p>Read: `<a href="#warnings">Warning</a>` usage conditions.</p> + +<h3>What are template extensions?</h3> + +<p>This configuration tool is powerfull for beginners and advanced users. +By FTP, in the template-extension folder, the Webmaster can duplicate a lot of + the distributed .tpl files ("original template") with a different name + ("replacer"). + + "Original templates", current original supported templates are:</p> +<ul> + <li><span class="filename">index.tpl</span></li> + <li><span class="filename">mainpage_categories.tpl</span> and/or <span class="filename">thumbnails.tpl</span></li> + <li><span class="filename">menubar.tpl</span></li> + <li><span class="filename">header.tpl</span> and/or <span class="filename">footer.tpl</span></li> + <li><span class="filename">picture_content.tpl</span> and/or <span class="filename">picture.tpl</span></li> + <!-- <li><span class="filename">slideshow.tpl</span></li> --> + <li><span class="filename">profile.tpl</span> and/or <span class="filename">profile_content.tpl</span></li> + <li><span class="filename">tags.tpl</span></li> + <li><span class="filename">upload.tpl</span></li> + <li><span class="filename">about.tpl</span></li> + <li><span class="filename">popuphelp.tpl</span></li> + <li><span class="filename">search.tpl</span> and/or <span class="filename">search_rules.tpl</span></li> + <li><span class="filename">nbm.tpl</span> and/or <span class="filename">notification.tpl</span></li> + <li><span class="filename">identification.tpl</span> and/or <span class="filename">register.tpl</span></li> + <li><span class="filename">redirect.tpl</span></li> +</ul> + +<h3>Where can I find "original templates"?</h3> + +<p>Distributed original templates are in template/yoga/ +(don't edit them in place for upgrade perspectives). So with "original templates", +any webmaster can create his "replacers (customized templates)".</p> + +<h3>Where should I save "replacers"?</h3> + +<p><strong>Replacers (customized templates)</strong> must be placed in the +template-extension folder (or its subfolders). +Replacers can have any filename with the .tpl extension. For example: <span +class="filename">template-extension/my-extension/video.tpl</span>.</p> + + +<h3>How can I activate my "replacers"?</h3> +<p>An <strong>original template</strong> should be assigned to each + <strong>replacer (customized templates)</strong> to activate the related replacements. + This is the goal of "Extend for templates" in the Configuration Administration menu.</p> + +<p>If you select an <strong>optional URL keyword</strong> then replacements +will be operate only on pages with this keyword. For example: <span + class="pwgScreen">index.php?/<strong>most_visited</strong></span></p> + +<p>Advanced users will use permalinks as <strong>optional URL + keyword</strong>. </p> +<h3>How can I deactivate my "replacers"?</h3> +<ul> +<li>Unselect related "Original templates".</li> +<li>By FTP delete of "replacers".</li> +</ul> +<a name="warnings"></a> +<h3>Warnings</h3> +<ul> + + <li><strong>Original template</strong> must be the "original" template + otherwise you could have unpredictable results!</li> + + <li>On several <strong>replacers (customized templates)</strong> with the + same<strong>Original template</strong> and the same <strong>optional URL + keyword</strong> only the last replacer is active.</li> + + <li>Unselected <strong>optional URL keyword</strong> will active the replacer + on any template usage. As previous point, order can override previous + selected replacers.</li> + + <li>Subfolders: +Subfolders are ignored but they are usefull to change current order.<br /> +distributed-samples: for test purpose are distributed! +<strong>Don't edit them</strong> create your own ones. +</li> + + <li>On delete of a replacer the <strong>Original template</strong> is + immediately reactivated.</li> + +</ul>
\ No newline at end of file diff --git a/language/fr_FR/admin.lang.php b/language/fr_FR/admin.lang.php index b1051c7a5..60981ae2e 100644 --- a/language/fr_FR/admin.lang.php +++ b/language/fr_FR/admin.lang.php @@ -649,4 +649,12 @@ $lang['Deleted on'] = 'Effacé le'; $lang['Last hit'] = 'Dernier accès'; $lang['Hits'] = 'Utilisations'; $lang['GD library is missing'] = 'la bibliothèque GD est manquante'; -?> +$lang['conf_extents'] = 'Templates (modèles)'; +$lang['extend_for_templates'] = 'Etendre les templates'; +$lang['Replacement of original templates'] = + 'Remplacement des templates d\'origine par vos templates adaptés du dossier template-extension'; +$lang['Replacers'] = 'Remplaçants (templates modifiés)'; +$lang['Original templates'] = 'Templates d\'origine'; +$lang['Optional URL keyword'] = 'Paramètre facultatif de l\'URL'; +$lang['Templates recorded.'] = 'La configuration des templates a été enregistrée.'; +?>
\ No newline at end of file diff --git a/language/fr_FR/help/extend_for_templates.html b/language/fr_FR/help/extend_for_templates.html new file mode 100644 index 000000000..8e2c7ac6b --- /dev/null +++ b/language/fr_FR/help/extend_for_templates.html @@ -0,0 +1,98 @@ +<h2>Extend for templates configuration</h2> + +<h3>Goal</h3> +<p>Define replacement conditions for each template from template-extension +(template called "replacer").</p> + +<p>"original template" from ./template/yoga (or any other than yoga) + will be replaced by a "replacer" if the replacer is linked to this "original template" + (and optionally, when the requested URL contains an "optional URL keyword").</p> + +<p>"Optional URL keywords" are those you can find after the module name in URLs.</p> + +<p>Therefore "Optional URL keywords" can be an active "permalink" +(see permalinks in our documentation for further explanation).</p> + +<p>Read: `<a href="#warnings">Warning</a>` usage conditions.</p> + +<h3>What are template extensions?</h3> + +<p>This configuration tool is powerfull for beginners and advanced users. +By FTP, in the template-extension folder, the Webmaster can duplicate a lot of + the distributed .tpl files ("original template") with a different name + ("replacer"). + + "Original templates", current original supported templates are:</p> +<ul> + <li><span class="filename">index.tpl</span></li> + <li><span class="filename">mainpage_categories.tpl</span> and/or <span class="filename">thumbnails.tpl</span></li> + <li><span class="filename">menubar.tpl</span></li> + <li><span class="filename">header.tpl</span> and/or <span class="filename">footer.tpl</span></li> + <li><span class="filename">picture_content.tpl</span> and/or <span class="filename">picture.tpl</span></li> + <!-- <li><span class="filename">slideshow.tpl</span></li> --> + <li><span class="filename">profile.tpl</span> and/or <span class="filename">profile_content.tpl</span></li> + <li><span class="filename">tags.tpl</span></li> + <li><span class="filename">upload.tpl</span></li> + <li><span class="filename">about.tpl</span></li> + <li><span class="filename">popuphelp.tpl</span></li> + <li><span class="filename">search.tpl</span> and/or <span class="filename">search_rules.tpl</span></li> + <li><span class="filename">nbm.tpl</span> and/or <span class="filename">notification.tpl</span></li> + <li><span class="filename">identification.tpl</span> and/or <span class="filename">register.tpl</span></li> + <li><span class="filename">redirect.tpl</span></li> +</ul> + +<h3>Where can I find "original templates"?</h3> + +<p>Distributed original templates are in template/yoga/ +(don't edit them in place for upgrade perspectives). So with "original templates", +any webmaster can create his "replacers (customized templates)".</p> + +<h3>Where should I save "replacers"?</h3> + +<p><strong>Replacers (customized templates)</strong> must be placed in the +template-extension folder (or its subfolders). +Replacers can have any filename with the .tpl extension. For example: <span +class="filename">template-extension/my-extension/video.tpl</span>.</p> + + +<h3>How can I activate my "replacers"?</h3> +<p>An <strong>original template</strong> should be assigned to each + <strong>replacer (customized templates)</strong> to activate the related replacements. + This is the goal of "Extend for templates" in the Configuration Administration menu.</p> + +<p>If you select an <strong>optional URL keyword</strong> then replacements +will be operate only on pages with this keyword. For example: <span + class="pwgScreen">index.php?/<strong>most_visited</strong></span></p> + +<p>Advanced users will use permalinks as <strong>optional URL + keyword</strong>. </p> +<h3>How can I deactivate my "replacers"?</h3> +<ul> +<li>Unselect related "Original templates".</li> +<li>By FTP delete of "replacers".</li> +</ul> +<a name="warnings"></a> +<h3>Warnings</h3> +<ul> + + <li><strong>Original template</strong> must be the "original" template + otherwise you could have unpredictable results!</li> + + <li>On several <strong>replacers (customized templates)</strong> with the + same<strong>Original template</strong> and the same <strong>optional URL + keyword</strong> only the last replacer is active.</li> + + <li>Unselected <strong>optional URL keyword</strong> will active the replacer + on any template usage. As previous point, order can override previous + selected replacers.</li> + + <li>Subfolders: +Subfolders are ignored but they are usefull to change current order.<br /> +distributed-samples: for test purpose are distributed! +<strong>Don't edit them</strong> create your own ones. +</li> + + <li>On delete of a replacer the <strong>Original template</strong> is + immediately reactivated.</li> + +</ul>
\ No newline at end of file diff --git a/template-extension/distributed/samples/my-picture.tpl b/template-extension/distributed/samples/my-picture.tpl new file mode 100644 index 000000000..4e81ff696 --- /dev/null +++ b/template-extension/distributed/samples/my-picture.tpl @@ -0,0 +1,35 @@ +{* $Id$ *} +<!-- This is a sample of template extensions --> +<div id="imageHeaderBar"> + <div class="browsePath"> + <a href="{$U_HOME}" rel="home">{'home'|@translate}</a> + {$LEVEL_SEPARATOR}{$SECTION_TITLE} + {$LEVEL_SEPARATOR}{$current.TITLE} + </div> +</div> + +{if !empty($PLUGIN_PICTURE_BEFORE)}{$PLUGIN_PICTURE_BEFORE}{/if} +<div id="imageToolBar"> + <div class="randomButtons"> + {if isset($PLUGIN_PICTURE_ACTIONS)}{$PLUGIN_PICTURE_ACTIONS}{/if} + </div> + {include file=$FILE_PICTURE_NAV_BUTTONS} +</div> <!-- imageToolBar --> + +<div id="theImage"> +{$ELEMENT_CONTENT} + +</div> + +{if isset($previous) } +<a class="navThumb" id="thumbPrev" href="{$previous.U_IMG}" title="{'previous_page'|@translate} : {$previous.TITLE}" rel="prev"> + <img src="{$previous.THUMB_SRC}" class="thumbLink" id="linkPrev" alt="{$previous.TITLE}"> +</a> +{/if} +{if isset($next) } +<a class="navThumb" id="thumbNext" href="{$next.U_IMG}" title="{'next_page'|@translate} : {$next.TITLE}" rel="next"> + <img src="{$next.THUMB_SRC}" class="thumbLink" id="linkNext" alt="{$next.TITLE}"> +</a> +{/if} + +{if !empty($PLUGIN_PICTURE_AFTER)}{$PLUGIN_PICTURE_AFTER}{/if} diff --git a/template-extension/distributed/samples/my-thumbnails.tpl b/template-extension/distributed/samples/my-thumbnails.tpl new file mode 100644 index 000000000..df39ab019 --- /dev/null +++ b/template-extension/distributed/samples/my-thumbnails.tpl @@ -0,0 +1,36 @@ +{* $Id$ *} +<!-- This is a sample of template extensions --> +{if !empty($thumbnails)} +<ul class="thumbnails"> +{foreach from=$thumbnails item=thumbnail} + <li> + <span class="wrap1"> + <span class="wrap2"> + <a href="{$thumbnail.U_IMG_LINK}"> + <img class="thumbnail" src="{$thumbnail.IMAGE}" alt="{$thumbnail.IMAGE_ALT}" title="{$thumbnail.IMAGE_TITLE}" /> + </a> + </span> + <span class="thumbLegend" style="color:#F36;"> + © 2008 Piwigo<br /> + {if !empty($thumbnail.ELEMENT_NAME)}{$thumbnail.ELEMENT_NAME}{/if} + {if !empty($thumbnail.IMAGE_TS)}{$thumbnail.IMAGE_TS}{/if} + + {if isset($thumbnail.NB_COMMENTS)} + <span class="{if 0==$thumbnail.NB_COMMENTS}zero {/if}nb-comments"> + <br /> + {$pwg->l10n_dec('%d comment', '%d comments',$thumbnail.NB_COMMENTS)} + </span> + {/if} + + {if isset($thumbnail.NB_HITS)} + <span class="{if 0==$thumbnail.NB_HITS}zero {/if}nb-hits"> + <br /> + {$pwg->l10n_dec('%d hit', '%d hits',$thumbnail.NB_HITS)} + </span> + {/if} + </span> + </span> + </li> +{/foreach} +</ul> +{/if}
\ No newline at end of file diff --git a/template-extension/distributed/samples/my-thumbnails2.tpl b/template-extension/distributed/samples/my-thumbnails2.tpl new file mode 100644 index 000000000..0f17542d1 --- /dev/null +++ b/template-extension/distributed/samples/my-thumbnails2.tpl @@ -0,0 +1,36 @@ +{* $Id$ *} +<!-- This is a sample of template extensions --> +{if !empty($thumbnails)} +<ul class="thumbnails"> +{foreach from=$thumbnails item=thumbnail} + <li> + <span class="wrap1"> + <span class="wrap2"> + <a href="{$thumbnail.U_IMG_LINK}"> + <img class="thumbnail" src="{$thumbnail.IMAGE}" alt="{$thumbnail.IMAGE_ALT}" title="{$thumbnail.IMAGE_TITLE}" /> + </a> + </span> + <span class="thumbLegend" style="color:#3F6;"> + © 2008 Piwigo<br /> + {if !empty($thumbnail.ELEMENT_NAME)}{$thumbnail.ELEMENT_NAME}{/if} + {if !empty($thumbnail.IMAGE_TS)}{$thumbnail.IMAGE_TS}{/if} + + {if isset($thumbnail.NB_COMMENTS)} + <span class="{if 0==$thumbnail.NB_COMMENTS}zero {/if}nb-comments"> + <br /> + {$pwg->l10n_dec('%d comment', '%d comments',$thumbnail.NB_COMMENTS)} + </span> + {/if} + + {if isset($thumbnail.NB_HITS)} + <span class="{if 0==$thumbnail.NB_HITS}zero {/if}nb-hits"> + <br /> + {$pwg->l10n_dec('%d hit', '%d hits',$thumbnail.NB_HITS)} + </span> + {/if} + </span> + </span> + </li> +{/foreach} +</ul> +{/if}
\ No newline at end of file |