Hey guys,
Is there a way to generate a list of articles by tag?
E.g. I want to list all articles with the tag "residential".
Well it works, but that's a terribly inelegant solution.
Thanks anyway, puffin2!
Articles has built-in support for tags and it's kind of working. You have to fix some bugs, more or less, depends on if you want to use Friendly URLs
---
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding
By terming it such, I'm not sure what you expect; you have to make a getResources snippet call to retrieve posts labeled with tags and that's about as simple as it gets.
Making a call based on a single tag is pretty easy; it's when you get into multiple tags that the problems begin to multiply. Tags are stored in a separate table in the db as strings separated by commas, so when characters overlap, you're forced to be creative in order to render the results you want. We need the modx team to come up with a better solution for multiple tags.
-
☆ A M B ☆
- 24,524 Posts
Actually this is a function of the add-on in question; MODx itself has nothing to do with it.
Susan, not sure what you mean exactly. Didn't the team develop Articles? Regardless who developed it, it seems that retrieving posts using tags is pretty limited in its present iteration.
Hey guys.
I'm not really a programmer I just read a few articles and mucked around a bit.
I worked out a way to Display a list of articles for multiple tags with get resources
You can make an array $blog_tag_search with all the tags you want to search (I did it this way cause my array is dynamic)
Eg
$blog_tag_search[0] = 'blabla';
$blog_tag_search[1] = 'tag2';
// this next part builds the search string to search the template variables using get resources
foreach($blog_tag_search as $listing) {
$tag_listing .= "'".$listing."' ";
$getResources_params['tvFilters'] .= "articlestags==%$listing%||";
}
/* this next part removes the last two || symbols to makes the tvfilters parameter valid */
$getResources_params['tvFilters'] = substr($getResources_params['tvFilters'],0,-2);
//echo $getResources_params['tvFilters'];
$getResources_params['includeContent'] = '1';
$getResources_params['includeTVs'] = '1';
//HERE IS YOU GET RESOURCES TEMPLATE FILE
$getResources_params['tpl'] = '2012_overview_articles_list';
$getResources_params['showHidden'] = '1';
$getResources_params['limit'] = '0';
$getResources_params['sortby'] = '{"pagetitle":"ASC"}';
// CHANGE TO THE ID OF YOUR "articles" PAGE (parent of your articles)
$getResources_params['parents'] = '591';
$output = $modx->runSnippet('getResources',$getResources_params);
//if there is output (i.e. a list) set the placeholder
if($output) {
return $output;
}