1

EE 2.7.2 Build20131008

I am fairly new to expression engine and having a little bit of trouble getting this to work out the way I need it.

I am trying to create a category archive page. Here is the code I have so far:

{exp:channel:category_heading}
<h2>Careers in {category_name}</h2>
{/exp:channel:category_heading}
{exp:channel:categories channel="careers" category="{category_id}" style="linear"}
<ul>
{exp:channel:entries channel="careers" category="{category_id}" orderby="date" sort="desc" disable="member_data" dynamic="no"}
<li>
<a href="{url_title_path='careers'}">{title}: ({career_location})</a>
</li>
{/exp:channel:entries}
</ul>         
{/exp:channel:categories}

The issue I have is that is doesn't seem to be pulling the "category_id" in the channel:entries tag. So I currently have 2 posts, both are assigned to 2 categories. So it actually renders a list of 4 posts, instead of just 2.

More Details

Here is a full layout of how things are setup:

Careers Channel with 2 category groups - location and department.

_desktop/careers pulls the careers listing. Currently have a select/dropdown on that page.

<form name="catmenu" action="">
<select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;">
    <option value="">--Select Category--</option>
    {exp:channel:categories channel="careers" category_group="2" style="linear"}
        <option value="{path='careers/listing'}/{category_id}">{category_name}</option>
    {/exp:channel:categories}
</select>
</form>

I created the careers/listing template as a "landing page" for when a category is selected. So lets say you select "Jobsville, NY" from the dropdown, it points to the careers/listing template with this URL:

domain.com/careers/listing/C37

Jobsville category id is "37". I can't figure out how to get it to spit out /careers/listing/category_name either.

On this listing page is where I have the code from the first part of my question. I currently have 2 posts.

  • Post 1 - assigned to location 1 and department 2
  • Post 2 - assigned to location 2 and department 2

The listing page is showing 2 copies of each post - not limiting the list to the category that I am currently viewing.

2
  • Can you edit your question to add an example url you are using for the page? If it is a category page you do not need to specify the category as a parameter in your entry. It will be picked up dynamically.
    – AllInOne
    Apr 3, 2017 at 14:53
  • More details added. Apr 3, 2017 at 15:41

1 Answer 1

0

On your listing template try simply omitting the category and dynamic parameters, like so:

{exp:channel:entries channel="careers" orderby="date" sort="desc" disable="member_data"}

If you want to switch from category IDs to category URL titles try this:

<option value="{path='careers/listing'}/category/{category_url_title}">{category_name}</option>

Documentation

4
  • Ok, that did a few different things. Removing the category and dynamic parameters made the listing page show a long list of the same entry over and over again. On the URL snippet, the URL now looks like domain.com/careers/listing/C37/category/cityname. How can I get it to just replace the C37 with the cityname? Apr 3, 2017 at 18:36
  • {path='careers/listing'}/category/{category_url_title} gives you domain.com/careers/listing/C37/category/cityname ? Really? Are you sure you don't still have {category_id} in there?
    – AllInOne
    Apr 3, 2017 at 19:24
  • Here is my full code for that drop down <form name="catmenu" action=""> <select name="selcat" onchange="location=document.catmenu.selcat.options[document.catmenu.selcat.selectedIndex].value;"> <option value="">--Select Category--</option> {exp:channel:categories channel="careers" category_group="2" style="linear"} <option value="{path='careers/listing'}/category/{category_url_title}">{category_name}</option> {/exp:channel:categories} </select> </form> Apr 3, 2017 at 19:56
  • Also still have the issue of that entries snippet looping and repeating the same single entry over and over. Apr 3, 2017 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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