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.

total Count of entries with certain status published by a user?

September 18, 2007 8:20pm

Subscribe [2]
  • #1 / Sep 18, 2007 8:20pm

    latrine

    28 posts

    I want EE to output a total number of entries that have a certain status and been published by the current user…

    I have tried to use:

    {exp:weblog:entries weblog="encomendas" status="submetida para cotacao" username="CURRENT_USER" }{count}{/exp:weblog:entries}

    wich produced something like:
    1234567n ->the count for each entry….

    but I want it to produce something like:
    n ->the count of total entries

    I also tried:

    {exp:weblog:entries weblog="encomendas" status="submetida para cotacao" username="CURRENT_USER" }{total_results}{/exp:weblog:entries}

    wich produced something like:

    77777777777 - one total result for each entry…, and if I limit to 1… off course the response will be just:

    1

    Is there a way to do this only using EE code?


    2- I have also tried to use the query tag like:

    {exp:query sql="SELECT COUNT(*) AS total_results FROM exp_weblog_title WHERE status='submetida para cotacao' AND ????????????????"} {total_results} {/exp:query}

    But I am lacking the code to “only count entries by current user”...
    Is there a EE variable that I overlooked?
    Can Anyone help on the ??????????????

    TIAdvance
    JPCarvalhinho

  • #2 / Sep 18, 2007 9:13pm

    Sue Crocker

    26054 posts

    Here’s an example to get you started. It’s using PHP on input in this case.

    <?php
    global $SESS;
    $member_id = $SESS->userdata['member_id'];
    $screen_name = $SESS->userdata['screen_name'];
    ?>
    {exp:query sql="select count(*) as cnt from exp_weblog_titles where author_id = <?php echo $member_id; ?> and status = 'open'"}
    {cnt} articles published by <?php echo $screen_name; ?>
    {/exp:query}

    In this case I’m using status of open, and not restricting based on the weblog_id.

    Does that help?  You can’t use CURRENT_USER outside of exp:weblog:entries.

  • #3 / Sep 19, 2007 6:07am

    latrine

    28 posts

    Thankyou SUE…

    I was hoping there was something I was overlooking on the EE side of things… I will implement this right away…

    😊

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases