Created
April 1, 2013 18:06
-
-
Save AgelxNash/5286571 to your computer and use it in GitHub Desktop.
[Evo] Облако тегов
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* TagPopular | |
* | |
* [[TagPopular? &tpl=`TagCloudItem` &tv=`7` &count=`15`]] | |
* | |
* TagCloudItem: | |
* <a href="/[~11~]?tag=[[urlencode? &input=`[+name+]`]]" title="Статьи с тегом [+name+]" class="label">[+name+] ([+count+])</a> | |
* | |
* @category snippet | |
* @version 0.1 | |
* @license GNU General Public License (GPL), http://www.gnu.org/copyleft/gpl.html | |
* @author Agel_Nash <Agel_Nash@xaker.ru> | |
*/ | |
$count = isset($count) ? (int)$count : 10; | |
$tv = isset($tv) ? (int)$tv : ''; | |
$out = array(); | |
$sql=$modx->db->query("SELECT ct.tv_id,t.name,count(ct.tag_id) as count FROM ".$modx->getFullTableName("tags")." as t LEFT JOIN ".$modx->getFullTableName("site_content_tags")." as ct ON ct.tag_id=t.id LEFT JOIN ".$modx->getFullTableName("site_content")." as c on c.id=ct.doc_id WHERE deleted=0 AND published=1 ".(($tv!='') ? ("AND ct.tv_id=".$tv) : "")." GROUP BY tag_id ORDER BY count(ct.tag_id) DESC LIMIT 0,".$count); | |
$sql=$modx->db->makeArray($sql); | |
foreach($sql as $item){ | |
$out[]=$modx->parseChunk($tpl,$item,"[+","+]"); | |
} | |
return implode((isset($outSep) ? $outSep : ""),$out); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment