From 8e6fe9f7e37fde57152c1448f1bf7090c8c1dee1 Mon Sep 17 00:00:00 2001 From: DrudexSoftware Date: Sun, 10 Mar 2013 08:24:15 +0100 Subject: [PATCH] - Random list page now has a title
- Custom Html Headers extension now allows admin to set title prefix & suffix for all pages --- ext/custom_html_headers/main.php | 95 +++++++++++++++++++++----------- ext/random_list/main.php | 1 + 2 files changed, 63 insertions(+), 33 deletions(-) diff --git a/ext/custom_html_headers/main.php b/ext/custom_html_headers/main.php index 99c1d94c..3ec05bef 100644 --- a/ext/custom_html_headers/main.php +++ b/ext/custom_html_headers/main.php @@ -1,33 +1,62 @@ - - * Link: http://www.drudexsoftware.com - * License: GPLv2 - * Description: Allows admins to set custom content - * Documentation: - * When you go to board config you can find a block named Custom HTML Headers. - * In that block you can simply place any thing you can place within - * - * This can be useful if you want to add website tracking code or other javascript. - * NOTE: Only use if you know what you're doing. - * - */ -class custom_html_headers extends Extension { - # Adds setup block for custom content - public function onSetupBuilding(SetupBuildingEvent $event) { - $sb = new SetupBlock("Custom HTML Headers"); - $sb->add_longtext_option("custom_html_headers", - "HTML Code to place within <head></head> on all pages
"); - $event->panel->add_block($sb); - } - - # Load Analytics tracking code on page request - public function onPageRequest(PageRequestEvent $event) { - global $config, $page; - - $header = $config->get_string('custom_html_headers',''); - if ($header!='') $page->add_html_header($header); - } -} -?> + + * Link: http://www.drudexsoftware.com + * License: GPLv2 + * Description: Allows admins to modify & set custom content + * Documentation: + * When you go to board config you can find a block named Custom HTML Headers. + * In that block you can simply place any thing you can place within + * + * This can be useful if you want to add website tracking code or other javascript. + * NOTE: Only use if you know what you're doing. + * + * You can now also add a prefix or suffix to your page title for SEO purposes + */ +class custom_html_headers extends Extension { + # Adds setup block for custom content + public function onSetupBuilding(SetupBuildingEvent $event) { + global $config; + + $sb = new SetupBlock("Custom HTML Headers"); + + // custom headers + $sb->add_longtext_option("custom_html_headers", + "HTML Code to place within <head></head> on all pages
"); + + // modified title + $sb->add_text_option("title_prefix", "
Page Title Prefix "); + $sb->add_text_option("title_suffix", "
Page Title Suffix "); + + $event->panel->add_block($sb); + } + + public function onInitExt(InitExtEvent $event) { + global $config; + + $config->set_default_string("title_prefix", ""); + $config->set_default_string("title_suffix", " - {$config->get_string("title")}"); + } + + # Load Analytics tracking code on page request + public function onPageRequest(PageRequestEvent $event) { + $this->handle_custom_html_headers(); + $this->handle_modified_page_title(); + } + + private function handle_custom_html_headers() { + global $config, $page; + + $header = $config->get_string('custom_html_headers',''); + if ($header!='') $page->add_html_header($header); + } + + private function handle_modified_page_title() { + global $config, $page; + + $page->title = $config->get_string("title_prefix") . + $page->title . $config->get_string("title_suffix"); + } +} +?> diff --git a/ext/random_list/main.php b/ext/random_list/main.php index b037d464..80ff36f4 100644 --- a/ext/random_list/main.php +++ b/ext/random_list/main.php @@ -14,6 +14,7 @@ class RandomList extends Extension { if($event->page_matches("random")) { // set vars + $page->title = "Random Images"; $images_per_page = $config->get_int("random_images_list_count", 12); $random_images = array(); $random_html = "Refresh the page to view more images