From bee51f53373aa6973a809fa5d6a6fd487e9d6426 Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Sun, 3 Jan 2010 23:26:58 +0000 Subject: An initial attempt at a module that will display a list of albums in the right sidebar. --- modules/album_block/helpers/album_block_block.php | 61 ++++++++++++++++++++++ modules/album_block/module.info | 3 ++ .../album_block/views/album_block_block.html.php | 8 +++ 3 files changed, 72 insertions(+) create mode 100644 modules/album_block/helpers/album_block_block.php create mode 100644 modules/album_block/module.info create mode 100644 modules/album_block/views/album_block_block.html.php (limited to 'modules') diff --git a/modules/album_block/helpers/album_block_block.php b/modules/album_block/helpers/album_block_block.php new file mode 100644 index 00000000..d469a0c7 --- /dev/null +++ b/modules/album_block/helpers/album_block_block.php @@ -0,0 +1,61 @@ + t("Album list")); + } + + static function get($block_id, $theme) { + $block = ""; + switch ($block_id) { + case "album_list": + $block = new Block(); + $block->css_id = "g-album-block"; + $block->title = t("Album list"); + $block->content = new View("album_block_block.html"); + + //$items = ORM::factory("item") + // ->viewable() + // ->where("type ==", "album") + // ->find_all(5); + + $items = ORM::factory("item")->where(array("type" => "album", "id !=" => 1))->orderby("updated", "DESC")->find_all(); + //if ($items->count() == 0) { + // Try once more. If this fails, just ditch the block altogether + //$items = ORM::factory("item") + //->viewable() + // ->where("type !=", "album") + // ->where("rand_key >= ", $random) + // ->orderby(array("rand_key" => "DESC")) + // ->find_all(1); + //} + + if ($items->count() > 0) { + #$block->content->item = $items->current(); + $block->content->items = $items; + } else { + $block = ""; + } + break; + } + + return $block; + } +} diff --git a/modules/album_block/module.info b/modules/album_block/module.info new file mode 100644 index 00000000..0a93532d --- /dev/null +++ b/modules/album_block/module.info @@ -0,0 +1,3 @@ +name = "Album Block" +description = "Display a list of albums in the sidebar" +version = 1 diff --git a/modules/album_block/views/album_block_block.html.php b/modules/album_block/views/album_block_block.html.php new file mode 100644 index 00000000..81660263 --- /dev/null +++ b/modules/album_block/views/album_block_block.html.php @@ -0,0 +1,8 @@ + + +
+ +<?php echo $item->title ?> + +
+ -- cgit v1.2.3