Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Better handling of furls for tags with modBlog

  • Loading branch information...
commit c133f92de5b1fe48c2183cb81c03e38482e7ab64 1 parent e619ff7
Shaun McCormick authored
View
2  core/components/taglister/elements/chunks/tag.chunk.tpl
@@ -1 +1 @@
-<li class="[[+cls]]"><a href="[[~[[+target]]? &[[+tagVar]]=`[[+tag]]` &[[+tagKeyVar]]=`[[+tagKey]]`]]">[[+tag]]</a> ([[+count]])</li>
+<li class="[[+cls]]"><a href="[[+url]]">[[+tag]]</a> ([[+count]])</li>
View
30 core/components/taglister/elements/snippets/taglister.snippet.php
@@ -26,6 +26,10 @@
/**
* tagLister snippet
*
+ * @var modX
+ * @var TagLister $tagLister
+ * @var array $scriptProperties
+ *
* @package taglister
*/
$tagLister = $modx->getService('taglister','TagLister',$modx->getOption('taglister.core_path',null,$modx->getOption('core_path').'components/taglister/').'model/taglister/',$scriptProperties);
@@ -53,6 +57,7 @@
$toLower = $modx->getOption('toLower',$scriptProperties,false);
$weights = $modx->getOption('weights',$scriptProperties,0);
$weightCls = $modx->getOption('weightCls',$scriptProperties,'');
+$useTagFurl = $modx->getOption('useTagFurl',$scriptProperties,false);
/* parents support */
$parents = isset($parents) ? explode(',', $parents) : array();
@@ -78,8 +83,16 @@
$c->where(array('TemplateVar.name' => $tv));
}
if (!empty($parents)) {
+ $children = array();
+ foreach ($parents as $parent) {
+ $kids = $modx->getChildIds($parent);
+ foreach ($kids as $kid) {
+ $children[] = $kid;
+ }
+ }
+ $children = array_unique($children);
$c->where(array(
- 'Resource.parent:IN' => $parents,
+ 'Resource.id:IN' => $children,
));
}
if (!$modx->getOption('includeDeleted',$scriptProperties,false)) {
@@ -147,7 +160,7 @@
/* handle weighting for css */
if (!empty($weights) && !empty($weightCls)) $tagCls .= ' '.$weightCls.ceil($count / (max($tagList) / $weights));
- $output[] = $tagLister->getChunk($tpl,array(
+ $tagArray = array(
'tag' => $tag,
'tagVar' => $tagVar,
'tagKey' => $tv,
@@ -156,7 +169,18 @@
'target' => $target,
'cls' => $tagCls,
'idx' => $i,
- ));
+ );
+ $tagParams = array();
+ if (empty($useTagFurl)) {
+ $tagParams[$tagVar] = $tag;
+ $tagParams[$tagKeyVar] = $tv;
+ }
+ $tagArray['url'] = $modx->makeUrl($target,'',$tagParams);
+ if (!empty($useTagFurl)) {
+ $tagArray['url'] = rtrim($tagArray['url'],'/').'/tags/'.str_replace(' ','+',$tag);
+ }
+
+ $output[] = $tagLister->getChunk($tpl,$tagArray);
$totalTags += $count;
$i++;
}
View
20 core/components/taglister/elements/snippets/tolinks.snippet.php
@@ -26,6 +26,10 @@
/**
* tolinks snippet. Creates links out of tags.
*
+ * @var modX $modx
+ * @var tagLister $tagLister
+ * @var array $scriptProperties
+ *
* @package taglister
*/
$tagLister = $modx->getService('taglister','TagLister',$modx->getOption('taglister.core_path',null,$modx->getOption('core_path').'components/taglister/').'model/taglister/',$scriptProperties);
@@ -40,6 +44,7 @@
$target = !empty($scriptProperties['target']) ? $scriptProperties['target'] : $modx->resource->get('id');
$tpl = $modx->getOption('tpl',$scriptProperties,'link');
$cls = $modx->getOption('cls',$scriptProperties,'tl-tag');
+$useTagsFurl = $modx->getOption('useTagsFurl',$scriptProperties,false);
/* get items */
$items = $modx->getOption('items',$scriptProperties,'');
@@ -65,14 +70,21 @@
foreach ($items as $item) {
$itemArray = array();
$itemArray['item'] = trim($item);
- $params = array(
- $tagRequestParam => $itemArray['item'],
- $tagKeyVar => $tagKey,
- );
+ $params = array();
+ if (empty($useTagsFurl)) {
+ $params = array(
+ $tagRequestParam => $itemArray['item'],
+ $tagKeyVar => $tagKey,
+ );
+ }
+
if (!empty($extraParams)) {
$params = array_merge($extraParams,$params);
}
$itemArray['url'] = $modx->makeUrl($target,'',$params);
+ if (!empty($useTagsFurl)) {
+ $itemArray['url'] = rtrim($itemArray['url'],'/').'/tags/'.$itemArray['item'];
+ }
$itemArray['url'] = str_replace(' ','+',$itemArray['url']);
$itemArray['cls'] = $cls;
$tags[] = $tagLister->getChunk($tpl,$itemArray);

0 comments on commit c133f92

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