ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

dynamic start_on not working!

March 04, 2009 9:16am

Subscribe [2]
  • #1 / Mar 04, 2009 9:16am

    DIY

    28 posts

    I am trying to create a list of the 10 most viewed entries, which have been posted within the past week.

    I copied the code from the docs, but I’m seeing what I believe to be the most popular entries of all time, rather than just those which have been put in to EE within the past 7 days.

    <?php
    global $LOC;
    $start_time = $LOC->decode_date('%Y-%m-%d %H:%i', $LOC->now - 604800);
    ?>
    
    {exp:weblog:entries weblog="news" limit="10" sort="desc" orderby="view_count_one" dynamic="off" start_on="<?php echo $start_time; ?>" sticky="off"}

    That’s the PHP I’m using as well as the opening entry tag - any help would be appreciated!

  • #2 / Mar 04, 2009 5:46pm

    Boyink!

    5011 posts

    I think it’s your “orderby=“view_count_one” that’s giving the the most popular entries.  Try removing that or specifying just a date sort.

  • #3 / Mar 06, 2009 6:19am

    DIY

    28 posts

    I would like it to show the most popular entries, but only those which have been added to the site in the past seven days - is this therefore not possible?

  • #4 / Mar 06, 2009 10:23am

    Boyink!

    5011 posts

    Seems like those should be able to be used together but it’s entirely possible that no one has tried it before. 

    EE Tech support folks?

  • #5 / Mar 10, 2009 8:52am

    DIY

    28 posts

    it’s entirely possible that no one has tried it before.

    Eek! It seems such a logical thing to want to do, too!

  • #6 / Nov 18, 2009 2:47pm

    mbroughton

    1 posts

    Was this ever resolved?  I’m having the same issue with the same code.

  • #7 / Nov 18, 2009 2:56pm

    ender

    1644 posts

    don’t know about using the weblog:entries tag to do it, but here’s a query that should do the same thing:

    SELECT
        t.entry_id,
        t.title,
        t.url_title,
        t.view_count_one,
        d.field_id_XX AS my_custom_field
    FROM
        exp_weblogs AS w NATURAL JOIN
        exp_weblog_titles AS t NATURAL JOIN
        exp_weblog_data AS d
    WHERE
        w.blog_name='news' AND
        t.entry_date > NOW()-604800 AND
        t.status='open'
    ORDER BY
        t.view_count_one DESC
    LIMIT 10;
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases