0

OK, I have a very simple task ahead, which, somehow got complicated.

I'm creating a simple blog in EE, with categories. Filtering posts by categories works just fine, however, I'm trying to display additional category information ("category_description" field), when I open specific category.

like: www.example.com/apples/ or www.example.com/oranges/ (i don't want to use reserved word like category, because it looks ugly :)

So what I want is, to pull my category info from url (eg. apples) from segment_2, - i got that working, and display the information from apples on the page.

Tried:

{exp:channel:category_heading category_id="1"}

  <h2>{category_name}</h2>
  <p>{category_description}</p>

{/exp:channel:category_heading}`

Displays NOTHING

Tried:

{exp:channel:categories category="20"}

    <h2>{category_name}</h2>
    <p>{category_description}</p>

{/exp:channel:categories}

Displays ALL categories with "list" tags (I just want ONE without list)

1
  • You say you are pulling your category 'apples' from segment_2 yet in your example it is in segment_1. – AllInOne Jun 12 '15 at 13:49
1

exp:channel:category_heading always use the URL to fetch data. There isn't a category_id parameter, despite it could be useful.

So, if you're not using the category word indicator and the parameter channel, your other option is the Query Module.

{exp:query sql="SELECT cat_name AS category_name, cat_description AS category_description FROM `exp_categories` WHERE cat_id = 1"}
  <h2>{category_name}</h2>
  <p>{category_description}</p>
{/exp:query}

You should not use segments on the query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.