- Random list page now has a title<br>

- Custom Html Headers extension now allows admin to set title prefix & suffix for all pages
This commit is contained in:
DrudexSoftware 2013-03-10 08:24:15 +01:00
parent e54c8439cb
commit 8e6fe9f7e3
2 changed files with 63 additions and 33 deletions

View File

@ -1,33 +1,62 @@
<?php <?php
/** /**
* Name: Custom HTML Headers * Name: Custom HTML Headers
* Author: Drudex Software <support@drudexsoftware.com> * Author: Drudex Software <support@drudexsoftware.com>
* Link: http://www.drudexsoftware.com * Link: http://www.drudexsoftware.com
* License: GPLv2 * License: GPLv2
* Description: Allows admins to set custom <head> content * Description: Allows admins to modify & set custom <head> content
* Documentation: * Documentation:
* When you go to board config you can find a block named Custom HTML Headers. * 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 <head></head> * In that block you can simply place any thing you can place within <head></head>
* *
* This can be useful if you want to add website tracking code or other javascript. * 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. * 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 <head> content class custom_html_headers extends Extension {
public function onSetupBuilding(SetupBuildingEvent $event) { # Adds setup block for custom <head> content
$sb = new SetupBlock("Custom HTML Headers"); public function onSetupBuilding(SetupBuildingEvent $event) {
$sb->add_longtext_option("custom_html_headers", global $config;
"HTML Code to place within &lt;head&gt;&lt;/head&gt; on all pages<br>");
$event->panel->add_block($sb); $sb = new SetupBlock("Custom HTML Headers");
}
// custom headers
# Load Analytics tracking code on page request $sb->add_longtext_option("custom_html_headers",
public function onPageRequest(PageRequestEvent $event) { "HTML Code to place within &lt;head&gt;&lt;/head&gt; on all pages<br>");
global $config, $page;
// modified title
$header = $config->get_string('custom_html_headers',''); $sb->add_text_option("title_prefix", "<br>Page Title Prefix ");
if ($header!='') $page->add_html_header($header); $sb->add_text_option("title_suffix", "<br>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");
}
}
?>

View File

@ -14,6 +14,7 @@ class RandomList extends Extension {
if($event->page_matches("random")) { if($event->page_matches("random")) {
// set vars // set vars
$page->title = "Random Images";
$images_per_page = $config->get_int("random_images_list_count", 12); $images_per_page = $config->get_int("random_images_list_count", 12);
$random_images = array(); $random_images = array();
$random_html = "<b>Refresh the page to view more images</b> $random_html = "<b>Refresh the page to view more images</b>