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.

Tricky Status Switch

August 20, 2008 12:05pm

Subscribe [2]
  • #1 / Aug 20, 2008 12:05pm

    jktress

    7 posts

    I’m not sure how to achieve the following effect.. If you look at my page http://beta.kyle2010.com, you’ll see that I have blog entries, as well as events/results on the index page. The events/results entries are organized as a single weblog with custom statuses of Upcoming or Complete. So far so good. However, when I change the status of an event from Upcoming to Complete (these are races, so I add results, and a little text), I would like that event to be reordered to appear as the first entry on the page.

    Is there a way to sort my weblog so events with a status of ‘Complete’ display as the first entry?

    Here’s the code I have for the index page right now.

    {exp:weblog:entries weblog="Posts|Events" limit="10" status="Open|Completed|Upcoming"}
        
        {if weblog == "Posts"}
        
        <div class="post">
         <h2><span>Blog - </span> <a href="http://{title_permalink=">{title}</a></h2>
    <p>      <br />
          Posted by {author} on {entry_date format="%M %d %Y"} | <a href="http://{title_permalink=" class="comments">{comment_total} comments</a> | posted in {categories}{category_name}{/categories}<br />
       {post_body}<br />
           {if post_image}<br />
          {post_image}<br />
        {/if}<br />
        </div><!--end post--><br />
      <br />
      {/if}<br />
      <br />
      {if weblog == "Events"}<br />
      <br />
      <div class="post"><br />
        {if status == "Upcoming"}<br />
          </p><h3>Event - <span><a href="http://{title_permalink=">{title}</a></span></h3>
    <p>      <strong>When:</strong> {event_date} <strong>Where:</strong> {event_location}<br />
        {/if}<br />
        <br />
        {if status == "Completed"}<br />
          </p><h3>Result - <span><a href="http://{title_permalink=">{title}</a></span></h3>
    <p>      <strong>When:</strong> {entry_date format="%M %d %Y"} <strong>Where:</strong> {event_location}<br />
        {/if}<br />
      </div><!--end post-->  <br />
      <br />
      {/if}<br />
      <br />
      {/exp:weblog:entries}

  • #2 / Aug 20, 2008 12:21pm

    Robin Sowell

    13255 posts

    Hm- I thought you could order by status, but a double check proved otherwise.  I can think of two main approaches- use a custom field to replicate the status- you can sort on a custom field.  Or- check out Reeorder- a third party plugin that plays on the same concept.  I suspect there may be others I haven’t spotted.

    It could also be done via pure php/custom plugin.

    That help?  Sorting by status would be the easiest way, but it’s not available.  (Might make for a good feature request, though.)

  • #3 / Aug 20, 2008 2:29pm

    Lisa Wess

    20502 posts

    You could also just set up two weblog entries tags, each with the status= that you need.

  • #4 / Aug 20, 2008 2:35pm

    jktress

    7 posts

    Thanks for the quick replies.. Lisa, I thought about that, but the problem I got was that all my posts appeared first, followed by my events. I would like them to appear together and in order. The exception would be events that have recently been completed, and have results. Those should appear first. I tried Reeorder, but the problem is it lists every single result at the top of the index page. I think the only way I can accomplish this is to manually update the ‘date’ field.

  • #5 / Aug 25, 2008 10:00pm

    Sue Crocker

    26054 posts

    jktress, what I do is create an additional weblog field called sort. In that dropdown field type, I put in the following;

    99
    01
    02
    03
    .. etc

    and order by sort asc.

    Example:

    {exp:weblog:entries weblog="faqs" orderby="qa_sort|title" sort="asc|asc"}

    Most of the time I want to sort by the title. 99 is the default for qa_sort, so most items are set to 99, and don’t influence the sort. But if needed, I can choose 01, 02, etc.

    Does that help?

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

ExpressionEngine News!

#eecms, #events, #releases