-
Notifications
You must be signed in to change notification settings - Fork 4
WordPress
Taxonomies (most notably categories and tags) have been with WordPress since the beginning. But they've been a bit of a late-comer to MODX. TagLister has been around for a while, and there's Tagger, and now, there's Taxonomies.
If you are like a lot of people, you are familiar with Taxonomies, but you may be at a loss for words when it comes down to describing the details as to how they work. Let's review some things point-by-point and explain where you might have seen these things and how you can get the same functionality out of the Taxonomies Extra.
First off, what are taxonomies? Well, you've probably heard of "Categories" and "Tags", and they are two examples of taxonomies. A Taxonomy is a group of terms in a certain context used to describe something. You can often think of terms as items in a dropdown list and the Taxonomy as the title to the list. E.g. if taxonomy is "Shape", then the terms might be "Square", "Circle", "Triangle" etc.
It's important to point out that taxonomies and terms can easily become blurred with "actual" data. It's important to acknowledge that yes, this distinction gets blurry, but the purpose of of taxonomies is to aid in classification so you can more easily find your data.
In most blogs, you are so used to seeing a list of terms for the current page that you sometimes skip right over it.
Look closely and you'll see something like the following tacked onto an article:
Categorized in: Guest Post, Health/Medicine Tags: aortic aneurysm, aortic dissection, aortic valve, cognitive impairment, pump head
Without even reading the article, you get some idea what it's about just by knowing how it has been tagged and categorized.
In WordPress, those lists are generated by one of a handful of functions somewhere in one of your templates:
- get_tags()
- get_the_tags()
- get_categories()
- get_the_category_list()
- get_the_category()
- ...and probably others...
So here you can see where I start going insane with the poor architecture inside WordPress -- there should NEVER be so many @#!$%!@# functions to do the same !@#%!@#* thing like this... deep breaths.
Inside MODX and the Taxonomies Extra, this list is generated by the getPageTerms Snippet. To reproduce the WordPress example, you could use 2 instances, one that retrieves categories, the other retrieves tags. Assume that the "Categories" folder page id is 123 and the "Tags" folder page id is 456, and your calls would look sometihng like this:
[[getPageTerms? &taxonomy_id=`123`]]
[[getPageTerms? &taxonomy_id=`456`]]
Let's revisit the absurdity of the WordPress world... you could have any number of taxonomies attached to your posts and pages, so it's crazy to have dedicated functions for each one. Here in the relatively sane world of MODX, we have ONE function that retrieves the terms in any given taxonomy. You want just terms? Adjust the &taxonomy_id. You want just categories? Adjust the &taxonomy_id. Format to taste.
Now that we've called attention to those little term-lists tacked onto posts, you already know what to expect if you ever click one of the links in the term list: it takes you to a "category page", something like http://yoursite.com/category/mammals/ and on that page you see a list of posts or pages that are IN the category you selected. Duh. But wait...
First, "Category Pages" is a terrible name -- you might be summarizing posts in a certain tag or shape or genre or whatever. A more appropriate name is a "Taxonomy Page" -- in fact, after several false starts, WordPress conceded in calling them that deep within their WP Template Hierarchy.
In the MODX world of the Taxonomy Extra, this is all laid out for you very transparently: you have taxonomies represented as FOLDERS, so you can see immediately if you're working with categories, tags, shapes, genres, or whatever. Terms are represented as MODX pages, so again, you can see immediately which terms are being used in a given taxonomy. And since these are MODX pages, what do you suppose is the logical thing to display on that page? E.g. what, pray-tell, would you put on the /categories/mammals/ page if it were a MODX site?
Hopefully you answered that you would put a list of pages that had been classified with that term. In the Taxonomies Extra, you would use the getPagesByTerm Snippet to do a "canned" search for any pages that have been classified with a given term.
[[getPagesByTerm]]
Or if you want to spruce up the formatting, maybe you use some custom Chunks or formatting strings:
[[getPagesByTerm? &outerTpl=`sometpl` &innerTpl=`othertpl` &limit=`0`]]
The Snippet can accept a &term_id to show results matching a specified term, but remember: the logical place for this snippet is ON the TERM PAGE, so the default value for the &term_id is the id of the current page.
Voilà : you have a list of pages matching the current term, and it's quite transparent. You see exactly where it is, and if you want to customize its template or its TVs, then you can modify it like any other MODX page.
Compare this transparency to WordPress: the "category pages" are not really pages... they are "magically" handled behind the scenes, and there's no visibility. If you want to change how their formatted, you have a lot more work in front of you.
The final bit of functionality that we are used to seeing on sites is a tag cloud. This typically shows a list of tags and a count of how many posts/pages are in each one. A variation on that is the size of the tag changes depending on its popularity: more posts equals bigger tag.
In MODX Taxonomies, we accomplish this via the getTagCloud Snippet. Poof. You can put this Snippet anywhere in your site, e.g. in a sidebar Chunk, and you can immediately provide links back to the aforementioned category pages and your users can quickly browse through your content according to its organization.
© 2014 and beyond by Craftsman Coding