We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Need Help Outputting Categories/Entries

How Do I?

rydedigital's avatar
rydedigital
18 posts
8 years ago
rydedigital's avatar rydedigital

Hi All,

I’m looking for a solution to output the below, but cant seem to get the switch value to close the DIV using what we have below.

https://ryde.digital/ee_ryde.txt

We cant get the count to close the divs using the switch method as the counts are inconsistent :/

Any help would be gratefully received.

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

The Channel Entries tag is not meant to be nested, as it is easy to make a small mistake and have excessive, site-killing looping. What you are seeing is the category tag parsing all of the count variables—it has no way of knowing your intention is that another tag will parse a {count} later. Will the category archives tag not do what you need?

       
rydedigital's avatar
rydedigital
18 posts
8 years ago
rydedigital's avatar rydedigital

Thanks Derek. I need to output images and custom field data within that loop - I didnt think that was possible with categories archive tag?

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Correct, that tag was conceived to help dissuade attempts at what I’m about to tell you to do, because depending on your content, this could get out of hand quickly. So to keep the performance zippy, the category archives tag leaves out custom fields. You’re needing to isolate the Channel Entries tag from the Categories tag, which is what embeds were designed to do. If you have hundreds of categories, let me know, because this would not be a performant solution in that instance:

Main template:

{exp:channel:categories category_group='4' style='linear' show_empty='no'}
 ...
 {embed='template_group/_cat_entries' category_id='{category_id}'}
 ...
{/exp:channel:categories}

template_group/_cat_entries:

{exp:channel:entries channel="team" category="{embed:category_id}" dynamic="no"}
 ...
{/exp:channel:entries}
       
rydedigital's avatar
rydedigital
18 posts
8 years ago
rydedigital's avatar rydedigital

Aha … fortunately there are only 3 categories, maybe 5 max so will try this now 😉

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Ok that should be just fine!

       
rydedigital's avatar
rydedigital
18 posts
8 years ago
rydedigital's avatar rydedigital

Hi Derek,

I tried this but unfortunately it just repeated each channel entry four times - thanks for trying though.

Ive had to result to this rather lengthy method for now to get us out of trouble but may come back to this when I get a mo.

https://ryde.digital/ee_ryde.txt

Thanks Scott

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

Did you mean to post a different set of template code? That looks like the same in your OP.

The sample I gave will output a Channel Entries tag for each category ID. You can check the Template tab of the debugger to see what resulting Channel Entries tags are being called. Are these entries in multiple categories within this category group by chance? That would cause them to be output once for each category they are in.

       
rydedigital's avatar
rydedigital
18 posts
8 years ago
rydedigital's avatar rydedigital

Hi Derek, try and refresh that file and it should load in - this is exactly what we are trying to achieve, albeit neatly and DRY but always seem to struggle with this kind of structure - maybe we are approaching it wrong but would be good to find a solid solution we can use as we tend to get a lot of sites structured this way.

Does the example highlight what we are trying to achieve?

       
Derek Jones's avatar
Derek Jones
7,561 posts
8 years ago
Derek Jones's avatar Derek Jones

That’s what the sample I shared above should ultimately output. Can you make sure you are trying this on a reduction template with no other tags than what I indicated above, and if that’s not working, share your full templates and the output from the Template tab of the Debugger?

Aside, you may want to replace the legacy {switch=} variables with modulus conditionals on count.

       
rydedigital's avatar
rydedigital
18 posts
8 years ago
rydedigital's avatar rydedigital

I had tried the modulus operator but reverted back to the switch whilst troubleshooting … hangs head in shame haha..

OK, I shall try these bits and get back to you … thanks for your time on this Derek, much appreciated.

       
rydedigital's avatar
rydedigital
18 posts
8 years ago
rydedigital's avatar rydedigital

Hi Derek, I have tried this again but it’s still outputting incorrect - I can give you access to the template if that helps - drop me an email ([email protected]) and I’ll send you the CP access if thats OK?

       
T Adams's avatar
T Adams
36 posts
8 years ago
T Adams's avatar T Adams

Hi Ryde,

Do you mind posting an example of the HTML you want to output? I might be able to help.

T.

       
rydedigital's avatar
rydedigital
18 posts
8 years ago
rydedigital's avatar rydedigital

Sure - we are trying to use Derek’s method above to output a DRY way of the example below:

https://ryde.digital/ee_ryde.txt

Thanks, appreciate your input 😉

       
T Adams's avatar
T Adams
36 posts
8 years ago
T Adams's avatar T Adams

Hi Ryde,

Thanks for that, I had seen the text file higher up in the thread. However, what I was looking for is the raw HTML you are trying to achieve. The way the multiple switches (especially the ‘|||’) are implemented are sort of throwing me. I was hoping see the compiled HTML might help clarify things.

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.