From: Jason Skomorowski Date: Mon, 24 Jan 2011 03:51:52 +0000 (+0100) Subject: Search blocks for nodes. You can even have more than one. X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=c972d1594d1e20759b5551874904d873c34e5ba7;p=mkdru-moved-to-drupal.org.git Search blocks for nodes. You can even have more than one. --- diff --git a/mkdru-block-search.tpl.php b/mkdru-block-search.tpl.php new file mode 100644 index 0000000..d816c93 --- /dev/null +++ b/mkdru-block-search.tpl.php @@ -0,0 +1,4 @@ +
+
+ +
diff --git a/mkdru.module b/mkdru.module index dc4f5b7..13ef18a 100644 --- a/mkdru.module +++ b/mkdru.module @@ -243,6 +243,10 @@ function mkdru_theme() { 'mkdru_js' => array( 'arguments' => array('node' => NULL), ), + 'mkdru_block_search' => array( + 'template' => 'mkdru-block-search', + 'arguments' => array('nid' => null, 'path' => NULL), + ), // 'mkdru_block_facet' => array( // 'template' => 'mkdru-block-facet', // 'arguments' => array('divId' => NULL), @@ -289,12 +293,21 @@ function mkdru_view($node, $teaser = FALSE, $page = FALSE) { function mkdru_block($op='list', $delta='sources', $edit=array()) { switch ($op) { case 'list': + // facet blocks + // NB: block caching is redundant for static content $blocks['mkdru_sources']['info'] = t('mkdru - source facets'); $blocks['mkdru_sources']['cache'] = BLOCK_NO_CACHE; $blocks['mkdru_subjects']['info'] = t('mkdru - subject facets'); $blocks['mkdru_subjects']['cache'] = BLOCK_NO_CACHE; $blocks['mkdru_authors']['info'] = t('mkdru - author facets'); $blocks['mkdru_authors']['cache'] = BLOCK_NO_CACHE; + // search blocks + $result = db_query("SELECT title, nid FROM {node} WHERE type = 'mkdru';"); + while ($node = db_fetch_object($result)) { + $blocks['mkdru_search_' . $node->nid]['info'] = + t('mkdru - search box for "' . $node->title . '"'); + $blocks['mkdru_sources']['cache'] = BLOCK_NO_CACHE; + }; return $blocks; case 'view': @@ -325,5 +338,10 @@ function mkdru_block($op='list', $delta='sources', $edit=array()) { $block['content'] = '
'; return $block; } + if (substr($delta, 0, 13) == 'mkdru_search_') { + $nid = substr($delta, 13); + $block['content'] = theme('mkdru_block_search', $nid, '/node/' . $nid); + return $block; + } } }