🌍
English
This shows you the differences between two versions of the page.
dev:compilation_of_personal_plugins [2013/01/18 11:12] mistic100 |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Compilation of personal plugins ====== | ||
- | Here is a list of very simple plugins you can use with [[http://piwigo.org/ext/extension_view.php?eid=144|LocalFilesEditor]]. | ||
- | |||
- | ==== Add a top navigation bar ==== | ||
- | On thumbnails list, if you have severals items, you may want to display the navigation bar on the top in addition to the bottom one. | ||
- | |||
- | <code php> | ||
- | <?php | ||
- | /* | ||
- | Plugin Name: Navbar on top | ||
- | Version: 1.0 | ||
- | Author: Mistic | ||
- | Author URI: http://www.strangeplanet.fr | ||
- | */ | ||
- | |||
- | add_event_handler('loc_end_index', 'top_navbar'); | ||
- | function top_navbar() | ||
- | { | ||
- | global $template; | ||
- | $template->set_prefilter('index', 'top_navbar_prefilter'); | ||
- | } | ||
- | function top_navbar_prefilter($content, &$smarty) | ||
- | { | ||
- | $search = '{if !empty($CATEGORIES)}{$CATEGORIES}{/if}'; | ||
- | $add = '{if !empty($navbar)}{include file=\'navigation_bar.tpl\'|@get_extent:\'navbar\'}{/if}'; | ||
- | return str_replace($search, $add.$search, $content); | ||
- | } | ||
- | ?> | ||
- | </code> | ||
- | |||
- | ==== Remove photo counter in the breadcrumb ==== | ||
- | <code php> | ||
- | <?php | ||
- | /* | ||
- | Plugin Name: Remove breadcrumb photocounter | ||
- | Version: 1.0 | ||
- | Author: barbichou | ||
- | */ | ||
- | |||
- | add_event_handler('loc_end_index', 'no_breadcrumb_counter'); | ||
- | function no_breadcrumb_counter() | ||
- | { | ||
- | global $template; | ||
- | $titre = $template->get_template_vars('TITLE'); | ||
- | $pos = strrpos($titre,"["); | ||
- | if ($pos !== false) | ||
- | { | ||
- | $template->assign('TITLE', substr($titre, 0, $pos)); | ||
- | } | ||
- | } | ||
- | ?> | ||
- | </code> | ||
- | |||
- | ==== One level page title ==== | ||
- | This plugins displays only the last album name in page title, not the full tree. | ||
- | |||
- | <code php> | ||
- | <?php | ||
- | /* | ||
- | Plugin Name: One level in page title | ||
- | Version: 1.0 | ||
- | Author:barbichou | ||
- | */ | ||
- | |||
- | add_event_handler('loc_end_page_header', 'one_level_pagetitle'); | ||
- | function one_level_pagetitle() | ||
- | { | ||
- | global $template, $conf; | ||
- | $titre = $template->get_template_vars('PAGE_TITLE'); | ||
- | $pos = strrpos($titre, $conf['level_separator']); | ||
- | if ($pos!==false) | ||
- | { | ||
- | $template->assign('PAGE_TITLE', substr($titre, $pos+strlen($conf['level_separator']))); | ||
- | } | ||
- | } | ||
- | ?> | ||
- | </code> | ||
- | |||
- | ==== Theme Switch From URL ==== | ||
- | This plugin allows to give URL with a additional parameter witch will force the current theme. | ||
- | For exemple : http://mysite.com/picture.php?/246/category/186&temp_theme=Stripped will open this picture page with the theme Stripped whatever is the default theme. | ||
- | Only works for picture page. | ||
- | |||
- | <code php> | ||
- | <?php | ||
- | /* | ||
- | Plugin Name: Theme Switch From URL | ||
- | Version: 1.0 | ||
- | Author: Mistic | ||
- | Author URI: http://www.strangeplanet.fr | ||
- | */ | ||
- | |||
- | add_event_handler('user_init', 'theme_controler_lite1'); | ||
- | add_event_handler('init', 'theme_controler_lite2'); | ||
- | |||
- | function theme_controler_lite1() | ||
- | { | ||
- | global $user; | ||
- | |||
- | if ( isset($_GET['temp_theme']) and file_exists(PHPWG_THEMES_PATH.$_GET['temp_theme']) ) | ||
- | { | ||
- | $user['theme'] = $_GET['temp_theme']; | ||
- | } | ||
- | } | ||
- | function theme_controler_lite2() | ||
- | { | ||
- | global $template; | ||
- | |||
- | if ( isset($_GET['temp_theme']) and file_exists(PHPWG_THEMES_PATH.$_GET['temp_theme']) ) | ||
- | { | ||
- | $template->assign('TEMP_THEME', $_GET['temp_theme']); | ||
- | $template->set_prefilter('picture', 'theme_controler_lite_prefilter'); | ||
- | } | ||
- | } | ||
- | function theme_controler_lite_prefilter($content) | ||
- | { | ||
- | global $conf; | ||
- | if ($conf['question_mark_in_urls']==false) | ||
- | { | ||
- | $search = '#(action|href)="([^?"]*)"#'; | ||
- | $replace = '$1="$2?temp_theme={$TEMP_THEME}"'; | ||
- | } | ||
- | else | ||
- | { | ||
- | $search = '#(action|href)="([^"]*)"#'; | ||
- | $replace = '$1="$2&temp_theme={$TEMP_THEME}"'; | ||
- | } | ||
- | |||
- | return preg_replace($search, $replace, $content); | ||
- | } | ||
- | ?> | ||
- | </code> | ||
- | |||
- | More to come... |