Tagging With Taxonomy

From VYRE

Jump to: navigation, search
Tagging with Taxonomy
Unify Tutorial
Unify Tutorial Series
Series Beginner
Unify Tutorial - Tagging with Taxonomy
Position in series 4
Previous in Series Adding Content
Prerequisites Building a Basic Site
Introducing Users and Permissions


Contents

Tagging with taxonomy ******** REVIEW *************

VYRE Unify uses a concept called taxonomy to tag and classify items. The taxonomy system allows the user to create tree structures of taxonomy categories, and then apply as many different categories to items. It is also possible to apply permissions to taxonomy categories to restrict the viewing of those items taxonomised by the restrictive categories.

Here is an example taxonomy structure describing a country hierarchy:

Image:Example_taxonomy.jpg

In this tutorial, we’re going to enhance our news site by creating a taxonomy structure for the continents of the world. We’ll then taxonomise some of our news articles with these categories and offer the user the ability to search the news by continent. Finally, we’ll create an archived news category, give it view restrictions and create a user group that has access to that category.


Creating the taxonomy tree

The taxonomy is managed in the configuration module under the System Configuration menu. Having some categories already added, it may look like the following:

Image:Taxonomy.manage.jpg

Note that by default the system only provides a root taxonomy category called Taxonomy, from which all other categories are descended. To create a new category, select the category you want to add to, right click and select Add subcategory (see this page for more details on how to manage taxonomy).

Create a tree with categories in the following structure:

Image:Region_tax_tree.jpg

Taxonomising Items

  1. Navigate to the news create page and edit the Item-Edit portlet.
  2. Expand the General tab, select the Taxonomy tree icon and save the default settings.
  3. Move it above the submit button
  4. Now we want to wrap the taxonomy tree in a < div >. To do this from within the General tab, select the "Custom code" icon. This offers you the ability to add any code you want. Insert an opening div element with an id of "tax" and move it above the taxonomy tree. Then add another custom code, insert a closing div and move that below the taxonomy tree.
  5. Deploy your changes and create some more news items, giving them a taxonomy category.

Searching for items by taxonomy category

Now that we have items with taxonomy categories, we’re going to create some ways for searching for items by taxonomy. Firstly, we’ll modify the Search portlet on the Admin news listing page to allow the searching by taxonomy.

  1. Edit the Search portlet and add the taxonomy tree from the General tab.
  2. When presented with the taxonomy tree options, tick the "Allow user to refine search by category selection".
  3. Under "Select root categories" select the "Continent" taxonomy category. This will force the system to display this branch only.
  4. Move the tree into a suitable position and save


As well as searching by taxonomy using the Search portlet, we can also use saved searches. These can be created in a similar fashion as before.


  1. Open the store you want to search (in our case it’s the News store)
  2. The taxonomy tree will be printed on the right. Click the category(s) you want to search, perform the search and then save the search.



  1. Create 4 saved searches to display each different type of published, regional news.
  2. Add 4 Search Results portlets to the regional news page, giving each one a different regional saved search.
  3. Modify your XSL to output the taxonomy category for that item between the following HTML code:


< div class = "titlebar" >
< div class = "parentsection floatright" >
< !—Output Category Here -- >
< /div >


By default, the taxonomy categories are rendered as XML in the categories node. In this format they are rendered as a flat structure with parent Id attributes defining the tree hierarchy. It is also possible to turn on tree based taxonomy rendering by ticking the "Show categories as taxonomy structure" option in the Search Results and Item – Display portlets. There are a few ways you could output this information. Two are briefly described below:

  1. Using the flat category structure, output the category with a specific parent id.
  2. Using the tree structure, apply-templates to the correct child node – this would also allow for items with more than one category.


Deploy your changes, and test in the front end.


Creating permissions with Taxonomy

To finish this chapter, we’re going to utilise taxonomy permissions to create our archived news and demonstrate how we can restrict / permit the viewing of items.

  1. Open the Taxonomy page from the configuration module, select the root taxonomy category and select Add subcategory in the context menu.
  2. Give it a suitable name, select View restricted and save.
  3. Now we need to create a user group that we’ll use to hold users who are allowed access to this category and then grant the relevant permissions to the group.

  4. Open the Users and Groups module and create a new group for archived news readers.
  5. Create a new user and add this user to the Archived news group.
  6. Go to Users and groupsTaxonomy ACLsPermissions.
  7. Select the groups you want to provide access to. It’s also important to provide access to any admin user that would do the tagging of items as archived.
  8. Select the category(-ies) you want to grant the access to by right clicking on it and granting view permission.

Deploy your changes, log in as your Web Admin user and create a few published but archived news articles. Log out and load the public news listing page. You should notice that your archived news articles are not displayed. Then, log in as your new archived news user and test viewing the articles.

Summary

This chapter focused on taxonomy and covered:

  • Creating taxonomy structures.
  • Tagging items with one or many taxonomy categories.
  • Searching for items by taxonomy.
  • Creating taxonomy based saved searches.
  • Taxonomy permissions
Personal tools