Display number of total files only once
Posted: 16 May 2008 05:48 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  318
Joined  03-07-2006

Hi all, I’ve make a basic entries loop where each entry adds a list item to a <ul> with a limit of 4. I also want to add a link to a page that displays all of the entries with a link that says “there are a total of X entries click here” (or if possible) “there are X more entries click here”

I can get the link in there but it repeats as its part of the loop PLUS I don’t want it as part of the list I want it outside.

This is what I have…

<ul class="diarydates">
    
{exp:weblog:entries weblog="diary" disable="member_data|pagination|trackbacks" category="9" show_future_entries="yes" orderby="date" sort="asc"}

                      
<li class="{switch="leftdl|rightdl"}"><h3>{diary-heading}</h3>
                        <
p>When is it? - <strong>{entry_date format="%d%S %F %Y"}</strong></p>
                        <
div class="explanation">{diary-summary}</div>
                      </
li>
<
p>There are a total of {total_results} Diary Dates, <a href="{title_permalink="/parents/diary/"}>Click here to see them all</a></p>
                        {/exp:weblog:entries}
                     
                    </ul>

Hope someone can help

 Signature 

· Confused… but happy ·

Profile
 
 
Posted: 16 May 2008 05:53 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  149
Joined  05-14-2008

I would separate them

<ul class="diarydates">
    
{exp:weblog:entries weblog="diary" disable="member_data|pagination|trackbacks" category="9" show_future_entries="yes" orderby="date" sort="asc"}

                      
<li class="{switch="leftdl|rightdl"}"><h3>{diary-heading}</h3>
                        <
p>When is it? - <strong>{entry_date format="%d%S %F %Y"}</strong></p>
                        <
div class="explanation">{diary-summary}</div>
                      </
li>
{/exp:weblog:entries}
                     
                    
</ul>

Then put this underneath

{exp:weblog:entries weblog="diary" disable="member_data|pagination|trackbacks" category="9" show_future_entries="yes" orderby="date" sort="asc" limit="1"}

<p>There are a total of {total_results} Diary Dates, <a href="{title_permalink="/parents/diary/""}>Click here to see them all</a></p>

{/exp:weblog:entries}

The limit one means it’ll only loop once and your total results paragraph is out of the list

 Signature 

Emily Griffiths | NuBlue Web Solutions | Lancaster UK

Profile
 
 
Posted: 16 May 2008 05:56 AM   [ Ignore ]   [ # 2 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  318
Joined  03-07-2006

Should have mentioned I’ve tried that and since its set to show only 1 the {total_results} only says 1 : ( thanks for the suggestion though.

 Signature 

· Confused… but happy ·

Profile
 
 
Posted: 16 May 2008 06:04 AM   [ Ignore ]   [ # 3 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

This should do what you want :

<ul class="diarydates">
{exp:weblog:entries weblog="diary" disable="member_data|pagination|trackbacks" category="9" show_future_entries="yes" orderby="date" sort="asc"}
<li class="{switch="leftdl|rightdl"}">
<
h3>{diary-heading}</h3>
<
p>When is it? - <strong>{entry_date format="%d%S %F %Y"}</strong></p>
<
div class="explanation">{diary-summary}</div>
</
li>
{/exp:weblog:entries}
</ul>

and then :

{exp:weblog:entries weblog="diary" disable="member_data|pagination|trackbacks" category="9" show_future_entries="yes" orderby="date" sort="asc"}
{if count
== "1"}
<p>There are a total of {total_results} Diary Dates, <a href="{title_permalink="/parents/diary/""}>Click here to see them all</a></p>
{/if}
{
/exp:weblog:entries}

Note that I have taken out the limit=“1” on the second weblog tag so we get a count of all the entries and also placed a conditional in to only show the message on the first entry

That should do it for you I think wink

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 16 May 2008 06:09 AM   [ Ignore ]   [ # 4 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

Actually just thinking about being clever with this you could also do this on the second weblog tag :

{exp:weblog:entries weblog="diary" disable="member_data|pagination|trackbacks" category="9" show_future_entries="yes" orderby="date" sort="asc" offset="4"}
{if count
== "1"}
<p>There are {total_results} more Diary Dates, <a href="{title_permalink="/parents/diary/""}>Click here to see them all</a></p>
{/if}
{
/exp:weblog:entries}

Note the addition this time of the offset=“4” parameter which should hopefully now make the {total_results} variable show you a number for the second style of text link you were after

Untested but should work wink

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 16 May 2008 06:23 AM   [ Ignore ]   [ # 5 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  149
Joined  05-14-2008

I’m going to put that count==“1” in my code library. Thanks Mark!

 Signature 

Emily Griffiths | NuBlue Web Solutions | Lancaster UK

Profile
 
 
Posted: 16 May 2008 06:29 AM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  318
Joined  03-07-2006

Thats perfect thanks Mark!

 Signature 

· Confused… but happy ·

Profile
 
 
Posted: 16 May 2008 06:47 AM   [ Ignore ]   [ # 7 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

No problem at all. Could have been done with a SQL query too I suppose but this way is slightly easier.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

Profile
 
 
Posted: 16 May 2008 06:50 AM   [ Ignore ]   [ # 8 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  318
Joined  03-07-2006

Ooop my eyes go crossed every time someone says “query” I hope to understand one day! (doozazzle)

Thanks again

 Signature 

· Confused… but happy ·

Profile
 
 
Posted: 16 May 2008 07:03 AM   [ Ignore ]   [ # 9 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  6610
Joined  04-15-2006

Yep a query may be slightly neater in this case (may be) but I always like to use standard tags wherever I can just to make things slightly easier on the brain for myself!! wink

Hope it all goes well for you.

Best wishes,

Mark

 Signature 

Full List Of Plugins Here!! (16)
 
Retrieve Statuses
Maximum Posts Reached
Neat Link
Redirect
Fetch URI

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 09:33 AM
Total Registered Members: 65087 Total Logged-in Users: 35
Total Topics: 82227 Total Anonymous Users: 21
Total Replies: 441926 Total Guests: 217
Total Posts: 524153    
Members ( View Memberlist )