Skip to content

Instantly share code, notes, and snippets.

@litzinger
Created May 31, 2012 17:54
Show Gist options
  • Save litzinger/2845059 to your computer and use it in GitHub Desktop.
Save litzinger/2845059 to your computer and use it in GitHub Desktop.
Taxonomy tweak
Index: /trunk/third_party/taxonomy/mod.taxonomy.php
===================================================================
--- /trunk/third_party/taxonomy/mod.taxonomy.php (revision 131)
+++ /trunk/third_party/taxonomy/mod.taxonomy.php (revision 132)
@@ -209,5 +209,5 @@
$r = ($tree_array != array(0)) ? $this->EE->ttree->build_list($tree_array, $str, $options) : '';
-
+
if($options['style'] == "nested")
{
@@ -472,5 +472,5 @@
{
- $tree_id = $this->_get_param('tree_id');
+ $tree_id = $this->_get_tree_id();
$entry_id = $this->_get_param('entry_id');
$include_current = $this->_get_param('include_current');
@@ -516,5 +516,5 @@
{
- $tree_id = (int) $this->_get_param('tree_id');
+ $tree_id = (int) $this->_get_tree_id();
$set_global = $this->_get_param('set_global', 'no');
$key = $this->_get_param('key');
@@ -856,13 +856,29 @@
function _get_tree_id()
{
- // do we have a globally set tree id (if the param is not set
- if($this->EE->TMPL->fetch_param('tree_id') == '' && isset($this->EE->session->cache['taxonomy']['this_node']['tree_id']))
- {
- $tree_id = $this->EE->session->cache['taxonomy']['this_node']['tree_id'];
+ if($tree_label = $this->EE->TMPL->fetch_param('tree_label'))
+ {
+ $qry = $this->EE->db->select('id')
+ ->where('LOWER(label)', strtolower($tree_label))
+ ->get('taxonomy_trees')
+ ->row();
+
+ if($qry->id)
+ {
+ $tree_id = $qry->id;
+ }
}
else
{
- $tree_id = (int) $this->EE->TMPL->fetch_param('tree_id');
- }
+ // do we have a globally set tree id (if the param is not set
+ if($this->EE->TMPL->fetch_param('tree_id') == '' && isset($this->EE->session->cache['taxonomy']['this_node']['tree_id']))
+ {
+ $tree_id = $this->EE->session->cache['taxonomy']['this_node']['tree_id'];
+ }
+ else
+ {
+ $tree_id = (int) $this->EE->TMPL->fetch_param('tree_id');
+ }
+ }
+
return $tree_id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment