Embed/include {pagination} tags? 
Posted: 07 September 2004 11:44 PM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  510
Joined  04-24-2004

Howdy all, I was >this< close to posting this as a feature request, but I figured I’d ask for ideas before I did. Basically I’m trying to modularise my templates so all common elements across the templates exist in their own individual template which is embeded/included as needs be. However I just discovered that of course you can’t embed the {pagination}{/pagination} code because embedded templates are parsed first. I also tried php includes, but juggling the input/output options didn’t work, and the snippets plugin didn’t work either. I’m using a tiny bit of php so the pagination links only appear when there are 2 or more pages, so I don’t get redudant “Page 1 of 1 pages” text. The code is as follows:

{paginate}
    <? $num_pages
= "{total_pages}";
    if (
$num_pages == "1"): ?>

    
<!-- nothing -->    

    
<? else : ?>
    
    
<div class="paginate">
    <
span class="pagecount">Page {current_page} of {total_pages} pages</span>  {pagination_links}
    
</div>
    
    
<? endif ?>
{
/paginate}

It would be nice to stick this in a template, but I don’t think its possible atm :| I realise this raises bigger questions than just how the {pagination} tags are parsed, but I’d appreciate any ideas! Cheers smile

 Signature 

lukestevensdesign.com · Design 2.0 · Pro Network member

Profile
 
 
Posted: 08 September 2004 04:38 AM   [ Ignore ]   [ # 1 ]  
Moderator
Avatar
RankRankRankRankRankRankRankRank
Total Posts:  31272
Joined  05-14-2004

You really can’t break up the containers like that, the paginate tags need to be within their containing element to know WHAT to paginate, so embedding them seperately simply won’t work.

I’m not sure if there is a feature request for this although I know people have tried breaking up things like exp:weblog:entries too so they may have posted feature requests. =)

 Signature 
Profile
MSG
 
 
Posted: 08 September 2004 02:10 PM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

Doing PHP includes is really the old route you can take if you want to abstract parts of EE tags.  But, as you found it can get tricky or impossible if you need other things in a Template to be parsed on ‘output’.

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 09 September 2004 09:32 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  510
Joined  04-24-2004

Yeah, I decided setting php parsing to input, using includes, and abstracting everything in the templates (entry title, summary etc) was better for my sanity. Can pass php variables to the includes as well. However this meant I could no longer manipulate the pagination tags with php (to test if {total_pages} = 1 or not). I just want to hide the text “Page 1 of 1 pages” but show it if there are more than 1 pages. So to get around this I used some CSS and markup magic like so:

{paginate}
    
<div class="paginate">
    
[b]<span class="pages{total_pages}">[/b]
        Page {current_page} of {total_pages} pages
</span>  {pagination_links}
   
</div>
{/paginate}

then in the css

.pages1 {display:none;}

which does the trick!

That said, a broader role for ee’s conditionals would be nice, so you could test the contents of any tag and use if/else logic for the result, which would be good, don’t you think?

 Signature 

lukestevensdesign.com · Design 2.0 · Pro Network member

Profile
 
 
Posted: 18 September 2004 10:03 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Rank
Total Posts:  43
Joined  04-19-2002

Awesome! I love clever workarounds like that.

Thanks.

Profile
 
 
Posted: 07 December 2004 02:07 PM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  220
Joined  05-25-2004

This is very clever, but it appears that EE is reporting that a single archive entry has 4 pages. Why would it do that?

See here:
http://blogs.oc.edu/ee/index.php?/chases/glow_stick_fun/

Profile
 
 
Posted: 07 December 2004 05:35 PM   [ Ignore ]   [ # 6 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  9868
Joined  06-19-2002

That page never resolved for me when I tried visiting.

What’s the full code for the {exp:weblog:entries} tag you’re using on the page?  (And is “glow_stick_fun” the URL Title corresponding to a particular entry?)

 Signature 

Chris Curtis
chriscurtis.org

Profile
 
 
Posted: 07 December 2004 09:33 PM   [ Ignore ]   [ # 7 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  220
Joined  05-25-2004

Ha.. Well, I copied that tag from a blog where it was working, even though I couldn’t tell a difference, and the problem disappeared.

Thanks!
dhl

Profile
 
 
Posted: 07 December 2004 09:34 PM   [ Ignore ]   [ # 8 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  220
Joined  05-25-2004

Yes, “glow_stick_fun” is a title. And I puzzled that you can’t access it.

Profile
 
 
Posted: 06 June 2007 11:57 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Avatar
Total Posts:  1
Joined  03-06-2006

I know that bumping old topics and so is not the best behaviour, but I think this might become handy for someone starting with templating and struggling with the pagination (and does not like the css-hack-thing)

I just use:

{paginate}{if {total_pages} != 1}
<div class="paginate"><span class="pagecount">Page {current_page} of {total_pages} Pages</span>  {pagination_links}</div>
{/if}{/paginate}

which works quite well for me.

Just for further explanation (if helpful?): The conditional in written English: If the total page-count is NOT equal to 1, display <div cl....

Profile
 
 
Posted: 09 July 2007 03:43 PM   [ Ignore ]   [ # 10 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  463
Joined  04-23-2006
Florian Pichler - 06 June 2007 11:57 PM

I know that bumping old topics and so is not the best behaviour, but I think this might become handy for someone starting with templating and struggling with the pagination (and does not like the css-hack-thing)

That is the best little/simple piece of coding I’ve seen in a long long time!

Thanks for sharing!

 Signature 

OLD username was jammo, NEW username is OrganizedFellow

It’s a struggle even to keep focused. This is the best of my AD/HD & GTD.
The exceptionally slow growth of my web dev projects is eclipsed by my patience, understanding and desire to learn AS MUCH AS POSSIBLE as I slowly progress.

Profile
 
 
Posted: 09 August 2007 12:32 PM   [ Ignore ]   [ # 11 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1457
Joined  03-26-2006

Cool, Florian, thanks. I just figured this out myself, and my syntax is a little different, but I get the same results. I’m adding this to my permanent bag of tricks.

{paginate}
{if {total_pages}
> 1}
<p>Page {current_page} of {total_pages} pages {pagination_links}</p>
{/if}
{
/paginate}

 Signature 

ryan masuga
Masuga DesignMember, EE Pro Network
Peruse my EE Plugins & Extensions

Profile
 
 
Posted: 15 July 2008 07:07 PM   [ Ignore ]   [ # 12 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1401
Joined  01-05-2007

Ha! I was just working on this and thankfully found this thread. I was scratching my head as I didn’t have the curly braces around total_pages.

Why wouldn’t it work without them?

 Signature 

 
Steven Hambleton | ExpressionEngine Development for Web & Graphic Design Agencies

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 10:33 AM
Total Registered Members: 61024 Total Logged-in Users: 25
Total Topics: 73808 Total Anonymous Users: 14
Total Replies: 398133 Total Guests: 471
Total Posts: 471941    
Members ( View Memberlist )
Newest Members:  b-rodMAIDENtreatstruckaungAdrian LeonP.T.Aoochoi2kfantomelIfTrueElseFalse