Order by date and view_count_one
Posted: 02 July 2008 02:05 PM   [ Ignore ]  
Grad Student
Rank
Total Posts:  34
Joined  03-06-2004

Moderator’s note: Moved to Howto.

I am trying to find a way to display a list of entries sorted by the month they were published and then the number of views for each article in descending order…

JUNE 2008
Article Z (234)
Article X (202)
Article Y (123)

MAY 2008
Article B (405)
Article C (309)
Article A (124)

I can do this by calling each month separately and ordering by view_count_one, but that leads to extra code for each month.

When I try to simplify the code like this, using the {date_heading} tag and calling multiple “orderby” commands…

{exp:weblog:entries weblog=“whatever” orderby=“date|view_count_one” sort=“desc|desc” year=“2008” rdf=“off” dynamic=“off”}
{date_heading display=“monthly”}
<h4>{entry_date format=”%F %Y”}</h4>
{/date_heading}
<p><a href=”{comment_entry_id_auto_path}”>{title}</a> ({view_count_one})</p>
{/exp:weblog:entries}

...I get only halfway. The entries are sorted by month, but within each month they are also sorted by date, not by view_count_one.

I suspect this is a logic problem. Any ideas?

Profile
 
 
Posted: 02 July 2008 02:33 PM   [ Ignore ]   [ # 1 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1055
Joined  06-05-2007

This is totally untested and just a stab at it, but try adding a second weblog:entires tag just to sort the view count titles. Like so:

{exp:weblog:entries weblog="whatever" orderby="date" year="2008" rdf="off" dynamic="off"}

{date_heading display
="monthly"}
<h4>{entry_date format="%F %Y"}</h4>
{/date_heading}

{exp
:weblog:entries weblog="whatever" orderby="view_count_one"}
<p><a href="{comment_entry_id_auto_path}">{title}</a> ({view_count_one})</p>
{exp:weblog:entries}

{
/exp:weblog:entries}

 Signature 

grantmx | designs - design | development | photography | consulting | ee pro profile

Profile
 
 
Posted: 02 July 2008 07:08 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  34
Joined  03-06-2004

No, that does not work. It throws the display into some sort of endless loop, repeating the last three months’ of entries.

Profile
 
 
Posted: 03 July 2008 12:52 AM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  582
Joined  04-29-2008

Greetings,

In lieu of giving the answer away easily, here is a snippet, tip, and parameter that might help out.

I see a tag that only fires monthly, and my little friend embed:

{embed="group/template" year="{entry_date format="%Y"}" month="{entry_date format="%n"}"}

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: 64915 Total Logged-in Users: 26
Total Topics: 81870 Total Anonymous Users: 21
Total Replies: 440150 Total Guests: 164
Total Posts: 522020    
Members ( View Memberlist )
Newest Members:  Suman KumarsmilepolitelyrvmcleodbjmohrAqua193Bios Elementmjpoteetguimogranwelshmrcf