aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@socioambiental.org>2013-11-19 16:01:21 -0200
committerSilvio <silvio@socioambiental.org>2013-11-19 16:01:21 -0200
commit4856e27936b1403dab3252322229bad0f63a41cf (patch)
tree70c2c2ad6c4c5a141d927578799b7ae0f8d28530
parent6c9ea9464077ce0454c5a5a2c0fb1f9f362e6825 (diff)
downloadjquery_drawer-4856e27936b1403dab3252322229bad0f63a41cf.tar.gz
jquery_drawer-4856e27936b1403dab3252322229bad0f63a41cf.tar.bz2
Implementing static cache at jquery_drawer_page()
-rw-r--r--jquery_drawer.module49
1 files changed, 27 insertions, 22 deletions
diff --git a/jquery_drawer.module b/jquery_drawer.module
index 682e506..5f759d3 100644
--- a/jquery_drawer.module
+++ b/jquery_drawer.module
@@ -185,31 +185,36 @@ function jquery_drawer_get_children($tid = NULL) {
* Menu callback.
*/
function jquery_drawer_page($tid = NULL) {
- $output = '';
- $nodes = taxonomy_select_nodes(array($tid));
- $base = variable_get('jquery_drawer_link', 'node');
- $tree = jquery_drawer_get_children($tid);
- $output .= '<ul id="drw_item" class="hidden">';
-
- // First render all nodes whose parent is $term
- while ($node = db_fetch_object($nodes)) {
- path_nodeapi($node,'load','');
- $link['title'] = $node->title;
- $link['href'] = ($node->path?$node->path:"$base/". $node->nid);
- $output .= theme('jquery_drawer_link', $link);
- }
+ static $cache = array();
- // Add other nodes
- if (is_array($tree) && !empty($tree)) {
- foreach ($tree as $term) {
- $output .= taxonomy_node_tree_list($term, 'jquery_drawer', 'hidden', $base);
+ if (!isset($cache[$tid])) {
+ $output = '';
+ $nodes = taxonomy_select_nodes(array($tid));
+ $base = variable_get('jquery_drawer_link', 'node');
+ $tree = jquery_drawer_get_children($tid);
+ $output .= '<ul id="drw_item" class="hidden">';
+
+ // First render all nodes whose parent is $term
+ while ($node = db_fetch_object($nodes)) {
+ path_nodeapi($node,'load','');
+ $link['title'] = $node->title;
+ $link['href'] = ($node->path?$node->path:"$base/". $node->nid);
+ $output .= theme('jquery_drawer_link', $link);
}
- }
- else {
- $output .= t('No content exists for this topic yet.');
- }
- $output .= '</ul></li>';
+ // Add other nodes
+ if (is_array($tree) && !empty($tree)) {
+ foreach ($tree as $term) {
+ $output .= taxonomy_node_tree_list($term, 'jquery_drawer', 'hidden', $base);
+ }
+ }
+ else {
+ $output .= t('No content exists for this topic yet.');
+ }
+
+ $output .= '</ul></li>';
+ $cache[$tid] = $output;
+ }
// Display output
echo($output);