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.

Sticky Posts

July 13, 2010 4:16pm

Subscribe [3]
  • #1 / Jul 13, 2010 4:16pm

    Rusty T.

    42 posts

    I’m having some difficulty here, and I’m sure there’s an easy solution I’m overlooking.

    I utilize ‘sticky’ posts from time to time—like most folks—and have an {if sticky=='y'} statement to add in an extra line of content for that sticky post (mainly a note that the entry is sticky and to scroll down for new content) that shows up only when an entry is sticky.

    What I’d like to change is to have the sticky post in a different format. I can easily do this using the {if}, but it then duplicates the entry with the sticky format at the top and then again at the top of the regular weblog entries.

    Is there a way to exclude sticky posts from showing in exp:weblog:entries?

    I’m using using 1.6.9 build 2010430.

    Here’s the code I’m currently using:

    {exp:weblog:entries weblog="{my_weblog}" show_expired="yes" orderby="date" sort="desc" limit="15" parse="inward"}
    <div class="regular">
                        {date_heading}
                            {entry_date format=' %l, %F %d, %Y '}
                        {/date_heading}
    
                        {title}
    
                        {if summary != ""}
                            {summary}
                        {/if}
    
                    {body}    
    
                    {if extended != ""}
                        <i><a href="http://{comment_url_title_auto_path}#more">Read more…</a></i>
    
    
                    {/if}
    
    
    {if  sticky=='y'} <i>This post is 'sticky.' Scroll down for new content.</i> {/if}
    
                        {author} {entry_date format='%h:%i %A'} |
                        {if forum_topic}
                            <a href="http://{path=forums/viewthread}{forum_topic_id}">Discuss on the forums</a>
                        {/if}
    
                        {if allow_comments}
                                ({comment_total}) <a href="http://{url_title_path=">Comments</a>
                        {/if}
        
                        | <a href="http://{permalink=site/friend}">Email this post</a> 
                        | <a href="http://{title_permalink={my_template_group}/index}">Permalink</a> 
                        | {if allow_trackbacks}({trackback_total}) <a href="http://{trackback_path=">Trackbacks</a>{/if}
                    </div>
    
                    {paginate}
                        <div class="paginate">
                            <span class="pagecount">
                                Page {current_page} of {total_pages} pages
                            </span>  
                            {pagination_links}
                        </div>
                    {/paginate}
    </div>
                {/exp:weblog:entries}
    What I’d like to do is something like this:
    {exp:weblog:entries weblog="{my_weblog}" show_expired="yes" orderby="date" sort="desc" limit="15" parse="inward"}
    {if  sticky=='y'}<div class="sticky"> {title}
    
                        {if summary != ""}
                            {summary}
                        {/if}
    
                    {body}    
    
                    {if extended != ""}
                        <i><a href="http://{comment_url_title_auto_path}#more">Read more…</a></i>
    
    
                    {/if}
    
                        {author} {entry_date format='%h:%i %A'} |
                        {if forum_topic}
                            <a href="http://{path=forums/viewthread}{forum_topic_id}">Discuss on the forums</a>
                        {/if}
    
                        {if allow_comments}
                                ({comment_total}) <a href="http://{url_title_path=">Comments</a>
                        {/if}
    
    <i>This post is 'sticky.' Scroll down for new content.</i> 
    </div>
    {/if}
    <div class="regular">
                        {date_heading}
                            {entry_date format=' %l, %F %d, %Y '}
                        {/date_heading}
    
                        {title}
    
                        {if summary != ""}
                            {summary}
                        {/if}
    
                    {body}    
    
                    {if extended != ""}
                        <i><a href="http://{comment_url_title_auto_path}#more">Read more…</a></i>
    
    
                    {/if}
    
                        {author} {entry_date format='%h:%i %A'} |
                        {if forum_topic}
                            <a href="http://{path=forums/viewthread}{forum_topic_id}">Discuss on the forums</a>
                        {/if}
    
                        {if allow_comments}
                                ({comment_total}) <a href="http://{url_title_path=">Comments</a>
                        {/if}
        
                        | <a href="http://{permalink=site/friend}">Email this post</a> 
                        | <a href="http://{title_permalink={my_template_group}/index}">Permalink</a> 
                        | {if allow_trackbacks}({trackback_total}) <a href="http://{trackback_path=">Trackbacks</a>{/if}
                    </div>
    
                    {paginate}
                        <div class="paginate">
                            <span class="pagecount">
                                Page {current_page} of {total_pages} pages
                            </span>  
                            {pagination_links}
                        </div>
                    {/paginate}
    </div>
                {/exp:weblog:entries}
  • #2 / Jul 13, 2010 8:41pm

    Brandon Jones

    5500 posts

    Greetings Rusty,

    As EE is behaving correctly I’m going to move this over to the CodeShare Corner where you can get input from the community. Thanks.

  • #3 / Jul 14, 2010 1:09am

    Rusty T.

    42 posts

    Thanks! Still trying to navigate this new layout.

  • #4 / Jul 14, 2010 5:44am

    Ingmar

    29245 posts

    You could still use the {if sticky=='y'} conditional: First, check if an entry is sticky then apply markup as needed for that plus the “stick entry warning” line, otherwise go with the regular markup. Shouldn’t be too difficult.

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

ExpressionEngine News!

#eecms, #events, #releases