Extension

Archived
Forum
(read-only)


For official support, visit the official support site »

Freebie

ExpressionEngine 2, ExpressionEngine 3

Back to this add-on's main page
View Other Add-ons From Rein de Vries

     

multiple pagination links /PX/PY with structure + freebie combination (conditional channel:entries)

Bug (Resolved)

mtin79
mtin79

hey doug,
as i am not sure which part causes the issue (structure or freebie or the interplay with rendering ee pagination links in a conditional) i wanted to ask you to have a look into the problem.

i am using the following code to test which cannel:entries tag to render depending on the value of cerstain freebie variables (see code snippet below).

the problem: although it renders only one set of links (which is correct) the pagination links content seems to be affected due to the number of {paginate} tags in the template as when for example the last condition is hit. i have pagination links in the format ..../PX/PX/PY/.... and not /PX

<div id="content">
                
{exp:channel:entries channel="medecine_chinoise"}
                    
<h1>{title}</h1>
                
{/exp:channel:entries}


                {if 
"{freebie_3}" == "categorie"}
                {exp
:channel:entries channel="medecine_chinoise_articles" category="{freebie_4}" dynamic="no"  limit="6" paginate="bottom" parse="inward"}
                    
...
                    
{paginate}
                        {if 
"{total_pages}" != 1} <hr />
                            
{pagination_links}
                        {
/if}
                    {
/paginate}
                {
/exp:channel:entries}
                {
/if}
                
                {if 
"{freebie_4}" == "categorie"}
                {exp
:channel:entries channel="medecine_chinoise_articles" category="{freebie_5}" dynamic="no"  limit="6" paginate="bottom" parse="inward"}
                    
...
                    
{paginate}
                        {if 
"{total_pages}" != 1} <hr />
                            
{pagination_links}
                        {
/if}
                    {
/paginate}
                    
                {
/exp:channel:entries}
                {
/if}
                
                {if 
"{freebie_3}" != "categorie" && "{freebie_4}" != "categorie"}
                {exp
:channel:entries channel="medecine_chinoise_articles" dynamic="no"  limit="6" paginate="bottom" parse="inward"}
                    
...
                    
{paginate}
                        {if 
"{total_pages}" != 1} <hr />
                            
{pagination_links}
                        {
/if}
                    {
/paginate}
                    
                {
/exp:channel:entries}
                {
/if}


            
</div

http://www.pastie.org/private/plybrh1adncn7swesuvdw

Doug Avery
# 1
Doug Avery

EE’s pagination is a little silly. I’m not really sure what could be causing this, BUT, what I would suggest is making one embedded template from the channel tag, then passing the categorie into it:

{if "{freebie_3}" == "categorie"}
  {embed
="content/blog" category="{freebie_4}"}
{if
:elseif .... }
  
...
{/if} 

Does that make sense?

mtin79
# 2
mtin79

Hey Doug,
thanks very very much for your feedback!
somehow embedding the channel with the pagination seemed to solve it.
(bow)

Doug Avery
# 3
Doug Avery

Cool! I’m guessing that EE handles pagination on a page level, so having those multiple tags in the same template messed it up. Weird EE tip: when you use conditionals, the actual order of operation is:

- Every tag on the page gets process and rendered
- THEN
- EE parses the conditionals and only shows the part you wanted
- THEN
- Embeds get parsed

This can lead to really brutal load times because it increases unnecessary MySQL queries. Using embeds for your channel tags, and wrapping them in conditionals, ensures that only the tags you need are processed.

mtin79
# 4
mtin79

hey doug. very valuable information again. really missed that one!