a wee weblog, since 2006

Quick start guide

A quick overview of Taxonomy, and how to get up and running quickly.

Download Taxonomy from GitHub

Is Taxonomy right for me?

Taxonomy is not right for you if:

  1. You don't know ExpressionEngine very well.

    If you've installed EE for the first time yesterday, it probably means that you shouldn't be dicking with third party addons right now. Go read the manual, understand how EE is primarily a dynamic system that breaks away from the 'pages' concept, and come back when you know you require a section or sections of your site to run off static, hierarchical content. And/or if you need your client to be able to edit certain menus around the site.

  2. Your client is an asshat

    You get quite a lot of control with this module, if you handover to a client that likes to fiddle where they shouldn't fiddle, Taxonomy is probably not a great choice for your project.

  3. You don't like free or open source software.

    Weirdo.

  4. Your site has 3 pages.

    C'mon, you really need a module to build a menu for 3 pages?

Tutorial

Planning is quite important with Taxonomy:

  1. The first bit is easy; Get a simple list of pages that you'll need for a particular section, here's the example we'll be using for this tutorial:

    About Our Company
    Community
    Customer Advisory
    Healthy Homes
    Sponsorship
    Careers
    Working for Us
    Current Vacancies
    Disclosures
    10 year Business Plan
    Environmental Policy
    Line Charges Pricing
    Residential Pricing
    Commerial Pricing
    Charges Terms & Conditions
    Our People
  2. Then, decide what type of content each page is going to comprise of.

    - Is every node in tree going to come from one channel called pages?
    - Is all content is going to be piped via a single template?...
    - or is it a mix of different content types (channels) with lots of different views (templates).

    I've added a couple of columns in the table to indicate how this simple tree is going to work in ExpressionEngine

    Pagetemplate / page urlContent Type / Channel
    About Our Company/aboutstatic_page
    Community/about/communitystatic_page
    Customer Advisory/about/customer_advisorystatic_page
    Healthy Homes/about/healthy_homesstatic_page
    Sponsorship/about/sponsorshipstatic_page
    Careers/about/careersstatic_page
    Working for Us/about/working_for_usstatic_page
    Current Vacanciescustom link to external site
    Disclosures/about/disclosuresstatic_page
    10 year Business Plan/about/business_planstatic_page
    Environmental Policy/about/environmental_policystatic_page
    Line Charges Pricing/about/line_charges_pricingstatic_page
    Residential Pricing/about/residential_pricingstatic_page
    Commerial Pricing/about/commercial_pricingstatic_page
    Charges Terms & Conditions/about/charges_termsstatic_page
    Our People/about/peoplestatic_page + people

    To keep things simple for the tutorial, most of the entries will come from one channel, and all the views will run through the /about/index template in ExpressionEngine. We also have 1 external link in our tree.

  3. Now we know what our tree is made up of, we can go ahead and do some ground work in EE, before we install Taxonomy.

    Two Channels are required here, one called static_pages to hold, um, static pages, and one for people so you can publish profiles for the people page. You can decide for yourself which fields you'll setup for those channels. To keep the tutorial simple, I'm just having one textarea for the static_page channel, and one textarea for the people channel. You'd most likely have a bunch of other fields too.

  4. Now we have our static_page channel, and our people channel. Go ahead and publish your first static_page, give it the title 'About Our Company' and enter the content for the very first page in our list above. (yes, I know, we haven't even installed Taxonomy yet...)
  5. Create a new template group called about

    Don't worry about adding any data into the template yet, just create the blank template for now.

  6. Install Taxonomy

    • Download Taxonomy from GitHub & rename the download folder to 'taxonomy'. Drop the /taxonomy directory into your /system/expressionengine/third_party/ directory
    • Visit Addons -> Modules & and install the Taxonomy Module and Fieldtype components.
    • Now visit the module, Addons -> Modules -> Taxonomy
    • You should be greeted by a fresh install screen like so:

    • You might as well add a custom Tab for quick access to the Taxonomy module while you're here :)
  7. Create Your First Tree

    • Click on Add a Tree button to begin creating your first tree, and review the options.

    • Enter 'About Menu' as the Tree Label, then select the /pages/index template, and select the Static Pages Channel
    • Then 'Create Tree'
    • You now should have your first tree:

  8. Add your first Node - Click on "About Menu" in the Manage Nodes Column - You will then be prompted to include a root node.

    - Copy the information from the screenshot above:
    - Give the node the label "About Our Company", this will be the label for the menu item.
    - Leave the template option blank, and select the entry "About our company" from the entry select
    - Now add /about in the url override.

    Why use the url override? Well, we want a nice clean url for the first page in our tree, in our list of pages we wanted the url /about on this page, and - we created a template group called /about so this node will be 'fixed' into place.

    Go ahead and click 'Add' - Awesome, we now have our first tree, and our first node. You should see the main tree management interface now.

    - Now we're going to leave the module like this for now, and get on with our template

  9. Head back to the /about template in the EE template manager

    • Here is the code we're going to use for the /about template

      {exp:channel:entries limit="1"}
      <html>
      <head>
      	<title>{title}</title>
      	<style>
      	.active > a {color: #000; font-weight: bold;}
      	</style>
      </head>
      <body>
      
      	<p id="crumbs">You are here: {exp:taxonomy:breadcrumbs tree_id="1" entry_id="{entry_id}"}</p>
      
      	<hr />
      
      	<h5>Navigation</h5>
      	{exp:taxonomy:nav tree_id="1" entry_id="{entry_id}"}
      	    <a href="{node_url}">{node_title}</a>
      	{/exp:taxonomy:nav}
      
      	<hr />
      
      	<h3>{title}</h3>
      
      	<p>{main_content}</p>
      
      </body>
      </html>
      {/exp:channel:entries}
    • As you can see, its a pretty simple template. I have some css in the head for styling the active navigation link, I've placed the Taxonomy breadcrumbs tag, the navigation tag, and my content tags into the template too.
    • Throw the code into the /about template, and save.
    • You should be able to visit mydomain.com/about and view a page similar to this:

    • Now, we need to make this page fixed... Because we're not passing a segment_2, this template is simply going to render the latest entry published into the static_page channel.

      We need to implicitly tell EE to render the about homepage, when segment_2 is missing

      First, find out the entry_id for the entry you published, and modify the first line of code in the about template to make sure the template plays ball.

      Replace this:

      {exp:channel:entries limit="1"}

      with

      {exp:channel:entries limit="1"{if segment_2 ==''} entry_id="43"{/if}}

      See what we've done?... if segment_2 is blank, render the entry with the id of 43. Obviously you'd want to replace '43' with the entry_id for the "About Our Company" page in your install.

  10. Now we're on the home run... Add the Taxonomy Field to your static_pages fields and get publishing!. Your publish page should look something like this, I've made the selections on the fieldtype so when we save, it'll go right into our Taxonomy tree.

  11. Go ahead and publish all the other pages in the tree (except for 'Current Vacancies' which is going to be an external link). When you're done, when you visit the Taxonomy module and edit the "About Menu" tree and it should look like this

  12. Now hover over any node in the tree and you'll see some buttons appear, click "view page" on any node, it will take you to the frontend of your site and fingers crossed ;) it'll look something like this:

That's all I've got time to show you right now, hopefully it'll give you enough to go on to flesh the module out a little more. Have a play and see what you think!

Try it with the pages module, there's a few treats in there if you do :)

If anyone actually reads this far let me know... I'll look to add more to the tutorial like how you can add dynamic sections with listings in your 'static' tree at some point.

As captured 8 January 2011 · The archived original