Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added a site="" parameter to {exp:taggable:entries}

  • Loading branch information...
commit cc49b8ae40f870f1530ac657ddb80ca347e17738 1 parent cb8e1fc
Jamie Rumbelow authored
3  docs/pages/module.html
@@ -98,6 +98,9 @@ <h3 id="entries">&#x7B;exp:taggable:entries&#x7D;</h3>
98 98
 <h4>Parameters</h4>
99 99
 
100 100
 <dl>
  101
+	<dt>site="not default_site"</dt>
  102
+	<dd>A site name, or multiple tag names separated by a bar. Optionally 'not'</dd>
  103
+	
101 104
 	<dt>tag_id="not 1|5"</dt>
102 105
 	<dd>A tag ID, or multiple tag IDs separated by a bar. Optionally 'not'</dd>
103 106
 	
1  third_party/taggable/ft.taggable.php
@@ -1022,6 +1022,7 @@ public function install() {
1022 1022
 		$tags_entries = array(
1023 1023
 			'tag_id' 	=> array('type' => 'INT'),
1024 1024
 			'entry_id'	=> array('type' => 'INT'),
  1025
+			'site_id'	=> array('type' => 'INT'),
1025 1026
 			'template'  => array('type' => 'VARCHAR', 'constraint' => 250, 'default' => 'tags')
1026 1027
 		);
1027 1028
 		
41  third_party/taggable/mod.taggable.php
@@ -155,7 +155,7 @@ public function url_name() {
155 155
 	 * Template tag for getting tag entries. Not recommended; only for
156 156
 	 * when you need to get from multiple channels. Use search: params instead.
157 157
 	 *
158  
-	 * {exp:taggable:entries tag_id="not 1|2" tag_url_name="not php|expressionengine" url_separator="-"}
  158
+	 * {exp:taggable:entries site="not site_a|site_b" tag_id="not 1|2" tag_url_name="not php|expressionengine" url_separator="-"}
159 159
 	 * 		<h1>Posts tagged with {tag_name}</h1>
160 160
 	 * 		{exp:channel:entries entry_id="{entries}"}
161 161
 	 *			<h1>{title}</h1>
@@ -163,9 +163,39 @@ public function url_name() {
163 163
 	 * {/exp:taggable:entries}
164 164
 	 */
165 165
 	public function entries() {
  166
+		$site			= $this->ee->TMPL->fetch_param('site');
166 167
 		$tag_id 		= $this->ee->TMPL->fetch_param('tag_id');
167 168
 		$tag_url_name 	= $this->ee->TMPL->fetch_param('tag_url_name');
168 169
 		$url_separator 	= ($this->ee->TMPL->fetch_param('url_separator')) ? $this->ee->TMPL->fetch_param('url_separator') : '-';
  170
+		$site_where		= FALSE;
  171
+		
  172
+		// Get the site ID(s)
  173
+		if ($site) {
  174
+			// Handle not
  175
+			if (substr($site, 0, 4) == 'not ') {
  176
+				$site = substr($site, 4);
  177
+				$site_not = TRUE;
  178
+			} else {
  179
+				$site_not = FALSE;
  180
+			}
  181
+			
  182
+			// Break up the site names
  183
+			$sites = array_filter(explode('|', $site));
  184
+			
  185
+			// Get the IDs
  186
+			$result = $this->ee->db ->select('site_id')
  187
+									->where_in('site_name', $sites)
  188
+									->get('sites')
  189
+									->result();
  190
+			$ids = array();
  191
+			
  192
+			foreach ($result as $row) {
  193
+				$ids[] = $row->site_id;
  194
+			}
  195
+			
  196
+			// Add a filer to the final result set
  197
+			$site_where = $ids;
  198
+		}
169 199
 		
170 200
 		// Tag URL name?
171 201
 		if ($tag_url_name) {
@@ -222,6 +252,15 @@ public function entries() {
222 252
 			}
223 253
 		}
224 254
 		
  255
+		// Site where!
  256
+		if ($site_where) {
  257
+			if ($site_not) {
  258
+				$this->ee->db->where_not_in('site_id', $site_where);
  259
+			} else {
  260
+				$this->ee->db->where_in('site_id', $site_where);
  261
+			}
  262
+		}
  263
+		
225 264
 		// Get the entry IDs and return
226 265
 		$this->ee->db->save_queries = TRUE;
227 266
 		$result = $this->ee->db->select('DISTINCT entry_id', FALSE)->get('taggable_tags_entries')->result();
8  third_party/taggable/upd.taggable.php
@@ -51,7 +51,7 @@ public function install() {
51 51
 		);
52 52
 		
53 53
 		$this->ee->db->insert('actions', $action);
54  
-						
  54
+		
55 55
 		// We're done!
56 56
 		return TRUE;
57 57
 	}
@@ -133,6 +133,12 @@ public function update($version = '') {
133 133
 		if ($version < 1.4) {
134 134
 			$this->ee->config->_update_config(array('taggable_default_theme' => 'taggable-tokens'));
135 135
 		}
  136
+		
  137
+		// Update from 1.4 to 1.5
  138
+		//    - Add site_id column to taggable_tags_entries
  139
+		if ($version < 1.5) {
  140
+			$this->ee->dbforge->add_column('taggable_tags_entries', array('site_id' => array('type' => 'INT', 'default' => '1')));
  141
+		}
136 142
 
137 143
 		return TRUE;
138 144
 	}

0 notes on commit cc49b8a

Please sign in to comment.
Something went wrong with that request. Please try again.