total_results with limit=“1”
Posted: 01 December 2008 12:06 PM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  10-16-2007

Hey guys

How do I solve this: I have a weblog with, say 30 entries in, but I want to display the total numbers of entries with only one loop, like below.
Like “absolute_count” but for weblog entries.
I would really rather do this without using a custom query.

{exp:weblog:entries weblog="shows" limit="1"}
  {total_results}
{
/exp:weblog:entries}

Tnx

 Signature 

André | Sweden
. pushloop.se

Profile
 
 
Posted: 01 December 2008 12:19 PM   [ Ignore ]   [ # 1 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7061
Joined  04-15-2006

Hiya,

Really if you want to just show total results and nothing else then a query may actually be better if you have a lot of entries. I know you say you don’t want to do it with a query but it would possibly save on the data being pulled out of the database. That being said with 30 entries you should be able to do something like this :

{exp:weblog:entries weblog="default_site"}

{if count
== "1"}
{total_results}
{
/if}

{
/exp:weblog:entries}

Using the code above even though the weblog tag is ready to spit out 9 results it will only spit out the {total_results} variable the once on the first iteration of the loop.

Hope that helps a bit.

Best wishes,

Mark

 Signature 

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

Profile
 
 
Posted: 01 December 2008 12:45 PM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  10-16-2007

I hear you Mark about the query saving data, and I just might give it a go if this turns out too heavy.
Thanks for the advice, it worked out just fine smile

 Signature 

André | Sweden
. pushloop.se

Profile
 
 
Posted: 01 December 2008 01:06 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  361
Joined  02-22-2005

If you only wanted to show the number of entries, would using the statistics module lighten the load any?

{exp:stats weblog="default"}
{total_entries}
{
/exp:stats}

Profile
 
 
Posted: 01 December 2008 01:37 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  186
Joined  10-16-2007

That would most certainly work, but in this case I might need to pull some other stuff from the weblog entries in the future.
Good advice though if anyone else with the same problem happens to stumble over this thread wink

 Signature 

André | Sweden
. pushloop.se

Profile
 
 
Posted: 01 December 2008 02:57 PM   [ Ignore ]   [ # 5 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  7061
Joined  04-15-2006

Glad that worked for you André. Thanks Dave for that tag as I had completely forgotten about that one!! wink

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: 66388 Total Logged-in Users: 40
Total Topics: 84713 Total Anonymous Users: 20
Total Replies: 454686 Total Guests: 188
Total Posts: 539399    
Members ( View Memberlist )