1
0

Update for Tags support.

This commit is contained in:
rWatcher 2009-08-12 00:34:46 -04:00
parent 9b48c339ef
commit 0c23fb7594
2 changed files with 22 additions and 9 deletions

View File

@ -19,20 +19,29 @@
*/ */
class metadescription_theme_Core { class metadescription_theme_Core {
static function head($theme) { static function head($theme) {
// Make sure the current page belongs to an item. if ($theme->tag()) {
if (!$theme->item()) { // If the current page belongs to a tag, look up
// the information for that tag.
$tagsItem = ORM::factory("tag")
->where("id", $theme->tag())
->find_all();
}elseif ($theme->item()) {
// If the current page belongs to an item (album, photo, etc.),
// look up any tags that have been applied to that item.
$tagsItem = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", $theme->item->id)
->find_all();
} else {
// If the current page is neighter an item nor tag, do nothing.
return; return;
} }
// Create an array of all the tags for the current item. // Load the meta tags into the top of the page.
$tagsItem = ORM::factory("tag")
->join("items_tags", "tags.id", "items_tags.tag_id")
->where("items_tags.item_id", $theme->item->id)
->find_all();
$metaView = new View("metadescription_block.html"); $metaView = new View("metadescription_block.html");
$metaView->tags = $tagsItem; $metaView->tags = $tagsItem;
return $metaView; return $metaView;
} }
} }

View File

@ -23,6 +23,10 @@
if ($metaDescription == "") { if ($metaDescription == "") {
$metaDescription = p::clean($item->title); $metaDescription = p::clean($item->title);
} }
// If it's still empty, use $metaTags.
if ($metaDescription == "") {
$metaDescription = $metaTags;
}
// Strip HTML // Strip HTML
$metaDescription = strip_tags($metaDescription); $metaDescription = strip_tags($metaDescription);
// Strip Line Breaks // Strip Line Breaks