1

I'm fairly new to Expressionengine, as I have taken over a site which a developer helped me build. So I'm still learning all the different things about it. My problem is this - I have a template (homepage) where I have four seperate {exp:channel:entries} tags.

So this is getting the feature.

{exp:channel:entries channel="channel1|channel2|channel3" limit="1"}

This is getting the four entries after the feature.

{exp:channel:entries channel="channel1|channel2|channel3" limit="4" paginate="bottom" offset="1"}

This is the tricky bit. The next {exp:channel:entries} tag occasionally repeats entries above even though I've set an offset of ('5' - counting the feature and four entries after)

{exp:channel:entries channel="channel1" limit="2" orderby="random" sort="desc" dynamic=“no” offset="5"}

Lastly, I have one that looks based on the category.

{exp:channel:entries channel="channel1|channel2|channel3" limit="2" category="111" orderby="random" offset="5"}

My question for this section: is there a way to stop it from posting entries if it is already being spat out by the other {exp:channel:entries} tags.

Please help me as I am fairly new to this. Would love any feedback. Thank you so much.

4 Answers 4

2

You might use Stash plugin. Keep appending the channel entries of previous channel and then exclude those within next channel entry tag. Like this example: https://github.com/croxton/Stash/wiki/%7Bexp%3Astash%3Aappend%7D

1
  • Could you give me an example of how this would work? Thanks Bhashkar for your reply.
    – Daniel M
    Sep 14, 2013 at 12:03
1

Use an embedded template, and do the other channel loops in there. In that template, pass in the entry IDs you don't want repeated:

{embed="includes/inner" excluded_ids="not 12|34|56"}

In the inner loop, in the channel entries tag, use entry_id="{embed:excluded_ids}"

1
  • Thanks for the reply, that makes sense. But how would I get the ids to put into the excluded_ids="" ?
    – Daniel M
    Sep 14, 2013 at 4:51
1

One possible solution is simple and might work for your situation, but it depends on how often the content is updated.

You could create a custom status for the second group, i.e.,

{exp:channel:entries channel="channel1|channel2|channel3" limit="4" status="2nd" paginate="bottom" offset="1"}

Only the entries marked with the 2nd status would appear there. The third group would have the channel:entries set as status="not 2nd".

It's an approach I use for one site and takes only a minute to update the statuses.

Otherwise, maybe the dynamic="no" in your third group is part of the problem.

0

Daniel,

Turn on your debugger and profiler.

The channel entries tag has some overhead - number of queries and sever memory. Look at the numbers in your debugger. As a guide, im happy with less than 40 queries, less than 6mb memory and response time less than 0.6 secs. If any of your numbers are way higher(double +) then you need to do some optimising.

On your home page you have 4 x channel entries. If you have plugins installed like matrix or channel images then the channel entries tags will be generating a lot of queries. This is not good for your home page because it will be slow to load.

But there is good news, i hope....

Your 'developer' would have been smart enough to add the disable param to the channel entries tag (and you removed it when you pasted in the code!). Something like this see docs

disable="categories|category_fields|custom_fields|member_data|pagination"

This will make the channel entries tag lighter/more efficient by reducing the amount of data returned.

Your 'developer' will have also cached the results of the channel entries tags in some way so that the queries dont need to be run every time someone hits the home page. Stash is a good solution here, but if you are new to EE, it may/will take you a while to get it. Hint think parse order

Whilst the suggestion of an embed is good, it adds additional overhead to your page load, which you should want to avoid in this case.

You also have paginate='bottom' for the second channel entries. Do you want to paginate these results? If so, every page of results you go to forces the other channel entries tag queries to be run AGAIN.

As a suggestion, we use stash to cache for 24 hrs the titles of 4 channel entries tags on one of our landing ages. We also gone a step further and used automatee plugin to rebuild this cache at midnight.

Aside from these performance tips ive given, youve been given two good answers on ways to meet specific need.

And, since youre new to the forum, if an answer assists you, ensure you mark it accordingly so others can benefit from your question + answer/s.

Good luck.

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.