Permalink
Browse files

Update for Tags support.

Signed-off-by: Bharat Mediratta <bharat@menalto.com>
  • Loading branch information...
1 parent d7ed217 commit 40b669e3d84fb4e7247fc528e42a635607e589fe rWatcher committed with bharat Aug 12, 2009
@@ -19,20 +19,29 @@
*/
class metadescription_theme_Core {
static function head($theme) {
- // Make sure the current page belongs to an item.
- if (!$theme->item()) {
+ if ($theme->tag()) {
+ // 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;
}
- // Create an array of all the tags for the current item.
- $tagsItem = ORM::factory("tag")
- ->join("items_tags", "tags.id", "items_tags.tag_id")
- ->where("items_tags.item_id", $theme->item->id)
- ->find_all();
-
+ // Load the meta tags into the top of the page.
$metaView = new View("metadescription_block.html");
$metaView->tags = $tagsItem;
return $metaView;
}
-
}
@@ -23,6 +23,10 @@
if ($metaDescription == "") {
$metaDescription = p::clean($item->title);
}
+ // If it's still empty, use $metaTags.
+ if ($metaDescription == "") {
+ $metaDescription = $metaTags;
+ }
// Strip HTML
$metaDescription = strip_tags($metaDescription);
// Strip Line Breaks

0 comments on commit 40b669e

Please sign in to comment.