splittingred / taglister Goto Github PK
View Code? Open in Web Editor NEWDisplays a list of tags that have been used on a site when using tags as a TV
Home Page: http://svn.modxcms.com/docs/display/ADDON/tagLister
Displays a list of tags that have been used on a site when using tags as a TV
Home Page: http://svn.modxcms.com/docs/display/ADDON/tagLister
Links generated by the 'tolink' snippet include the character '&' instead of '&', which causes html validation errors.
I fixed this problem on my test site by adding the following line to the 'tolink' snippet code: $itemArray['url'] = str_replace('&','&',$itemArray['url']);
immediately after the line:
$itemArray['url'] = str_replace(' ','+',$itemArray['url']);
Problem: tagLister gathers/counts all tags in documents. Works fine.
But I have different sections of documents (journal, magazin, blog) and I need different tags counts on different parent trees.
getResouresTag is already able to work with specified parents to display specified documents by tag. But tagLister would need also a parameter for listing/counting only these documents I want to have for exmaple from the journal tree. It is possible to use different tvs but it would be wishful that tagLister works also with children of parents to give full support to getResourcesTag.
problem: taglister operates usualy for a blog tags application. The functionality could be expand to authors and html site keywords.
Nearly all what's to edit for advance is this in tagLister :
/* get TV values */
$c = $modx->newQuery('modTemplateVarResource');
$c->innerJoin('modTemplateVar','TemplateVar');
$c->innerJoin('modResource','Resource');
$tvPk = (int)$tv;
if (!empty($tvPk)) {
$c->where(array('TemplateVar.id' => $tvPk));
} else {
$c->where(array('TemplateVar.name' => $tv));
}
In the case of authors, one would use modWebUserProfile (createdby, fullname) instead of modTemplateVarResource.
In the case of site_keywords, it is imho modResource, modResourceKeyword.
Then you get 2 more useful applications by minimal changes.
for example
/?tag=book
then that could pull items that have the tag 'FaceBook' and 'Books' instead of just the items tagged with 'book'
If you set the System Setting for link_tag_scheme to "abs", the URLs that this makes are not absolute: they still come through as relative because the default 4th argument is used for modx's makeUrl() function. The parser reads the System Setting correctly; this Snippet should do the same.
Hi Shaun.
Title hopefully explains - but discovered this morning that if tagLister is called with 'parents' defined, then tagLister seems to look for child documents only (and doesn't include the parent document for analysis). Am using tagLister in a template that needs to output a list of 'subject' tags for the parent doc, as well as any child documents it may have...but many don't have children.
Have found a fix, and wondered if you'd consider it for a future update.
SQL error reported in MODX error log when no child documents found for a specified parent:
[2012-03-10 14:33:16](ERROR @ /index.php) Encountered empty IN condition with key id
[2012-03-10 14:33:16](ERROR @ /index.php) Error 42000 executing statement:
Array
(
Resource
.deleted
= '0' AND Resource
.published
= '1' )' at line 1*Have been able to resolve with some modifications to tagLister.snippet.php:
$children = array();
foreach ($parents as $parent) {
$pchildren = $modx->getChildIds($parent, $depth);
if (!empty($pchildren)) $children = array_merge($children, $pchildren);
}
Replace lines 86-98 with the following code:
if (!empty($parents)) {
$children = array();
foreach ($parents as $parent) {
$pchildren = $modx->getChildIds($parent, $depth);
if (!empty($pchildren)) $children = array_merge($children, $pchildren);
}
if (!empty($children)) {
$children = array_unique($children);
$parents = array_merge($parents, $children);
}
$parents = array_unique($parents);
$c->where(array(
'Resource.id:IN' => $parents,
));
}
This modification forces tagLister to include the parent docs, as well as any discovered children, and also removes the need for duplicate '$modx->getChildIds' as it appears in original code.
Solution now working in my client's site.
Hope this all makes sense.
Thanks for a great snippet, and all the coding effort around MODX...amazing platform :)
there is a bug line 36 of getResourcesTag, if you want to personnalize the name of the Get parameter with tolinks
"if (!empty($_GET['tag'])) {"
should be
"if (!empty($_GET[$tagRequestParam]))"
Like &sortBy=RAND()
in getResources.
When using getResourcesType and setting tagSearchType, using 'beginswith' will find pages with tags ending with the search phrase, and using 'endswith' will find pages with tags beginning with the search phrase.
I'm just assuming this was supposed to work the other way around :)
getResourcesTag properties is missing the "pageActiveTpl" parameter.
Its not a big issue but just wanted to mention it.
Temporary solution: when using a property set for getResourcesTag you can add "pageActiveTpl" parameter manualy.
But it would be nice if its in the properties by default.
Консоль запущена...
Пробуем установить пакет с подписью: taglister-1.1.7-pl
Пакет найден... сейчас идёт подготовка к его установке.
Загрузка рабочего пространства пакета...
Рабочее пространство загружено, сейчас устанавливаем пакет...
modx.modNamespace is deprecated since version 3.0. Replace references to class modx.modNamespace with MODX\Revolution\modNamespace to take advantage of PSR-4 autoloading.
modNamespace is deprecated since version 3.0. Replace references to class modNamespace with MODX\Revolution\modNamespace to take advantage of PSR-4 autoloading.
modNamespace is deprecated since version 3.0. Replace references to class modNamespace with MODX\Revolution\modNamespace to take advantage of PSR-4 autoloading.
modx.modCategory is deprecated since version 3.0. Replace references to class modx.modCategory with MODX\Revolution\modCategory to take advantage of PSR-4 autoloading.
modCategory is deprecated since version 3.0. Replace references to class modCategory with MODX\Revolution\modCategory to take advantage of PSR-4 autoloading.
modCategory is deprecated since version 3.0. Replace references to class modCategory with MODX\Revolution\modCategory to take advantage of PSR-4 autoloading.
modSnippet is deprecated since version 3.0. Replace references to class modSnippet with MODX\Revolution\modSnippet to take advantage of PSR-4 autoloading.
modSnippet is deprecated since version 3.0. Replace references to class modSnippet with MODX\Revolution\modSnippet to take advantage of PSR-4 autoloading.
modSnippet is deprecated since version 3.0. Replace references to class modSnippet with MODX\Revolution\modSnippet to take advantage of PSR-4 autoloading.
Успешно установлен пакет taglister-1.1.7-pl
If a tag contains German Umlauts getResourcesTag does not list these.
Add urldecode to lines 39,41,43,45 this will fix it:
stripTags(urldecode($_GET[$tagRequestParam]))
Taglister has an default output limit of 10 items. Changing the limit to for example &limit=20
does not result in an output of 20 items. Still 10 are shown (the 10 most recent ones).
I tried &limit=0
and other figures as well, but taglister still keeps showing 10 items only.
Anyone got a clue?
When FURL mode on and when target resource is main page taglister makes links for tags without this resources' alias.
for example with resource called 'news' it makes link for tag "products" like this: http://aaa.com/tags/products instead of http://aaa.com/news/tags/products
Also, in tagLister there is problem with furlKey argument, it is used several times in context:
...empty($furlKey)
but it always has default value, so it is never empty.
Hi there!
I have a crazy problem with the tag-filter of getResourcesTag...
Let's imagine, A, B, C and D are blog-posts. 1, 2 and 3 are tags.
A is tagged with 1, 2, 3
B is tagged with 1, 2
C is tagged with 2, 3
D is tagged with 1, 3
Okay, now click on the link of tag 1. You will see posts A, B, D. All right. If you click on another link (2 for example), you'll see nothing...
That's the problem I have right now at this site: http://modx.dennis-schubert.de/blog/
My call:
[[!getResourcesTag?
&element=getResources
&elementClass=modSnippet
&tpl=cbBlogListItem
&tagKey=cbBlogPostTags
&hideContainers=1
&pageVarKey=page
&parents=[[+parents]]
&includeTVs=1
&includeContent=1
&tagRequestParam=tag
]]
[[!+page.nav:notempty=<div class="paging"> <ul class="pageList"> [[!+page.nav]] </ul> </div>
]]
toLinks are pointing to that resource
A TV was created to serve as a tag field. The TV contains geographical values (French Departments - same idea as a County) and the majority are the same. So I specified this as the default value. The default value shows correctly in non-tagging circumstances, but when used by the TagLister snippet itself it is ignored. The solution is to not define a default value.
When a tag is submitted (from tolinks for example) and it contains non ascii chars like ï ë ä ö and such, everything works fine.
Exept when printing the [[!_tag]] to screen (im using it as longtitle: Articles containing the tag "[[!_tag]]") there goes something wrong with character encoding/decoding.
ï -> for example shows -> ï
Hi folks,
I wish a tagLister with a sortBy publishedon
, for eg: (ABCD are blog-post)
A is tagged with Software (A is published 2 days ago)
B is tagged with Software (B is published a month ago)
C is tagged with Hardware (C is published today)
D is tagged with Networking (D is published 3 days ago)
so, instead of default sortBy tag
or count
parameter, when you do tagLister it would be :
cheers,
When a resource has tags but is hidden in menu, somtimes its good to hide the tags in taglister for those documents as well, I see in the code that you can set published and deleted options, so I copied one of those and changed it to hidemenu, for me this works not until I update it.
Currently, if you have a tag which includes a subset of another tag, e.g.
"fuzzy brown bunny" and "brown bunny"
the default action is to return both when you ask for "brown bunny". This is problematic if, for example, two distinct organizations exist with similar names and you only want things tagged with one or the other. Switching to the exact match results in matching resources tagged only with the requested tag. So if a rabbit resource is tagged with both "brown bunny" and "rodent" it won't show up, although it would be highly desirable behavior.
Matching "fuzzy brown bunny" seems like a false positive and leads to confusion. Matching resources tagged with "brown bunny" that happen to have other tags, however, seems like normal behavior for tagging.
We use taglister a lot for filtering wit isotope.js there we do not need an link for the tags, so we do not set the target. In the snippet it defaults to id 1, but when you would remove this resource or when using other contexts, this id is not availible and would return a lot of makeurl errors in the logs.
2 options here, 1 if target is not set us current resource id, or 2: skip the whole make url part if target is not set.
Could you build in Friendly URL's into these snippets, just like it's done with Archivist?
Possibility to pass a context parameter to the tagLister snippet. I have multiple contexts for all languages I want, but my blog is going to be English only. But.. I wasn't able to show the tags listing because the $modx->getChilIds() gets the IDs of the current context.
I had to change
$kids = $modx->getChildIds($parent,$depth);
into
$kids = $modx->getChildIds($parent,$depth,array('context' => 'english'));
Would be great if this is configurable as parameter
At line 44: $altCls = $modx->getOption('cls',$scriptProperties,'tl-tag-alt');
shouldn't it be $altCls = $modx->getOption('altCls',$scriptProperties,'tl-tag-alt'); ?
Documentation example:
[[!tolinks? &items=[[*tags]] &key=tag &target=123]]
No matter how I define "&key" I get "&key=tags" in the end of all generated links.
I.e. _ tags _ instead of _ tag _.
EDIT:
Adding &tagKey to [[toLinks]] generates that as &key value in link url. That makes sorting work! :)
Either call it empty or using the TV-name :) Just somewhat confusing.
I miss the ability to make a template for the output of toLinks.
Now it just outputs a list of links, but I also like to output it as a unordered list.
Invalid REVO ticket reposted here: feature request
See forumthread: http://modxcms.com/forums/index.php/topic,56107.0.html
Perhaps it might be handy to make a custom snippet call with an extra 'tagRequestParam' possible, which is still overruled by http://URL?tag=`othertag`.
Additional code could be just an extra else-if-statement in the snippet code:
else if(!empty($$tagRequestParam)){
$scriptProperties['tvFilters'] = $tagKey.'==%'.$modx->stripTags($$tagRequestParam).'%';
}
tagLister doesn't seem to take account of whether a user has the policy to view a resource when creating the output.
getResourcesTag does - presumably through getResources
eg I have a member-only page tagged Foo and a public page tagged Foo.
Anonymous user sees Foo (2), instead of Foo (1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.