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.

Looking for help with conditional stmt and viewing articles with draft status

February 10, 2011 10:21pm

Subscribe [7]
  • #1 / Feb 10, 2011 10:21pm

    JulesWebb

    271 posts

    I am trying to set it up so that the super admin and manager can see articles with the status of “Draft”

    Below is the code I am using.  When I view the page I can see articles with the status of “Announcement” and “Open” but not “Draft” I’m redirected to my 404 page.  I’ve used this same idea in an EE2 site and it works great.  I can’t figure out what it is I’m doing wrong here and am hoping that one of you will.

    thanks
    Jules

    {if logged_in_group_id == 1 || logged_in_group_id == 6  } 
    
        <!-- =========================================================== -->    
        <!-- !        ARTICLES LISTED IF SUPER ADMIN OR MANAGER          -->
        <!-- =========================================================== -->  
        {exp:weblog:entries weblog="equine-news" limit="1" status="Announcement|Open|Draft" disable="member_data|pagination" }   
            
            <div class="postheader clearfix">
                <span class="date"><strong>{entry_date format="%M"}</strong>{entry_date format="%j"} <small>{entry_date format="%Y"}</small></span>
                <h3 class="title-post"><a href="http://{title_permalink=">{exp:xml_encode}{title}{/exp:xml_encode}</a></h3>
                <h4 class="author-post clearfix">               
                    <span class="trans-none floatleft">By </span>
                    <span class="floatleft">{author} </span>
                    <span class="trans-none floatleft"> | Category(s):</span>
                    <span class="categories floatleft">{categories show="not 6" limit="2"}<a href="http://{path=">{category_name}</a> <br>{/categories}</span>                              
                </h4>
            </div><!-- /postheader -->               
            
            <div class="share-this">                    
                [removed][removed]
            </div>
            
            {article-body}
            
        {/exp:weblog:entries}   
        
    {/if}
    
    {if logged_out}              
               
    {exp:weblog:entries weblog="equine-news" limit="1" status="Announcement|Open" disable="member_data|pagination" }
    
         blah blah blah
    
    {/exp:weblog:entries}
    
    {/if}
  • #2 / Feb 11, 2011 11:40am

    Ingmar

    29245 posts

    That should work, yes. Are you trying this as a Superadmin? do you have other statuses? You might want to try “not Closed” for Superadmins. The statuses short name is “Draft”, with a capital D? Also, what version and build of EE are you using?

  • #3 / Feb 11, 2011 8:09pm

    JulesWebb

    271 posts

    Are you trying this as a Superadmin?

    Yes

    do you have other statuses?

    Below are the statuses I have:
      Open  
      Closed  
      Draft  
      Announcement

    You might want to try “not Closed” for Superadmins

    I updated my tag to:
    {exp:weblog:entries weblog="equine-news" limit="1" status="Announcement|Open|Draft" status="not Closed" disable="member_data|pagination" }
    I was still redirected to 404 page

    The statuses short name is “Draft”, with a capital D?

    All the statuses begin with a capital.

    what version and build of EE are you using?

    ExpressionEngine 1.6.9 - Build:  20100430
    yeah, I know I need to upgrade, I’m hoping that this isn’t the reason for the issue.  I’ve only done one other upgrade and I’m a bit gun-shy.
    This was my first EE site and I am currently developing my second EE site (using EE2)

  • #4 / Feb 12, 2011 4:19pm

    Greg Salt

    3988 posts

    Hi Jules,

    Please change your tag back to only have one ‘status’ parameter. If I understand you correctly what is happening is that your template is not recognising that you are logged in. Is that correct? Can you please simplify this a little bit by changing the first conditional to be just this for the moment:

    {if group_id == 1}
    I am logged in
    ... rest of your code

    Does that show you the ‘I am logged in’ text?

    Cheers

    Greg

  • #5 / Feb 12, 2011 5:19pm

    JulesWebb

    271 posts

    If I understand you correctly what is happening is that your template is not recognising that you are logged in. Is that correct?

    The template is recognizing that I’m logged in.  If you look at the original thread I submitted the comment (pasted below) is inside the conditional statement.  When I look at the source code of the page I see that comment when I’m looking at any article on the site (when I’m logged in) If I’m not logged in that comment does not show.

    {if logged_in_group_id == 1 || logged_in_group_id == 6  } 
    <!-- =========================================================== -->    
    <!-- !        ARTICLES LISTED IF SUPER ADMIN OR MANAGER          -->
    <!-- =========================================================== -->
  • #6 / Feb 13, 2011 3:55pm

    Greg Salt

    3988 posts

    Hi Jules,

    Can you share a link for the site and page where this is supposed to be working? Also, can you clarify this:

    When I view the page I can see articles with the status of “Announcement” and “Open” but not “Draft” I’m redirected to my 404 page.

    I don’t understand how you can see some articles but are also redirected to the 404 page.

    Cheers

    Greg

  • #7 / Feb 13, 2011 4:29pm

    ECKwa

    16 posts

    don’t understand how you can see some articles but are also redirected to the 404 page.

    That statement did it, I mean really why would I be redirected?  I opened up my template and found the reason at the top.

    {exp:weblog:entries weblog="equine-news" limit="1" disable="member_data|comments|trackbacks|pagination" status="open|Announcement" require_entry="yes" url_title="{segment_3}"}
    {if no_results}{redirect="site/404"}{/if}
    {embed="includes/DOC-head" url_title="{segment_3}" 
        title_prefix=""
        title_suffix="{categories show="not 6" backspace="1" limit="2"}{category_name} |{/categories}" 
        hide_site_title="n"
     }
    {/exp:weblog:entries}

    So is the best course to use {if logged_in} and {if logged_out} here as well?

  • #8 / Feb 14, 2011 4:07am

    John Henry Donovan

    12339 posts

    Jules,

    That statement did it, I mean really why would I be redirected?  I opened up my template and found the reason at the top

    Are we talking about the same template still? Where does that template block fit in with your original template you posted? Can you update this thread with what you have in place now

    So is the best course to use {if logged_in} and {if logged_out} here as well?

    You could use those simple conditionals yeah but they also cover regular members being logged in. If you don’t have a membership site and are only limited to SuperAdmins then yes these tags will be fine

  • #9 / Feb 14, 2011 3:59pm

    JulesWebb

    271 posts

    Are we talking about the same template still? Where does that template block fit in with your original template you posted? Can you update this thread with what you have in place now

    Yes, see code below

    {exp:weblog:entries weblog="equine-news" limit="1" disable="member_data|comments|trackbacks|pagination" status="open|Announcement" require_entry="yes" url_title="{segment_3}"}
    {if no_results}{redirect="site/404"}{/if}
    {embed="includes/DOC-head" url_title="{segment_3}" 
        title_prefix=""
        title_suffix="{categories show="not 6" backspace="1" limit="2"}{category_name} |{/categories}" 
        hide_site_title="n"
     }
    {/exp:weblog:entries}
    
    <body id="secondary_header">
    
    {embed="includes/header-subpg"}
    
    <div class="midcontent">     
          <div class="container_12"> 
            <div class="grid_8 single-post">
                <div class="content entry">   
                
                {if logged_in_group_id == 1 || logged_in_group_id == 6  } 
    
                    <!-- =========================================================== -->    
                    <!-- !        ARTICLES LISTED IF SUPER ADMIN OR MANAGER          -->
                    <!-- =========================================================== -->  
                    {exp:weblog:entries weblog="equine-news" limit="1" status="Announcement|Open|Draft" status="not Closed" disable="member_data|pagination" }   
                        
                        <div class="postheader clearfix">
                            <span class="date"><strong>{entry_date format="%M"}</strong>{entry_date format="%j"} <small>{entry_date format="%Y"}</small></span>
                            <h3 class="title-post"><a href="http://{title_permalink=">{exp:xml_encode}{title}{/exp:xml_encode}</a></h3>
                            <h4 class="author-post clearfix">               
                                <span class="trans-none floatleft">By </span>
                                <span class="floatleft">{author} </span>
                                <span class="trans-none floatleft"> | Category(s):</span>
                                <span class="categories floatleft">{categories show="not 6" limit="2"}<a href="http://{path=">{category_name}</a> <br>{/categories}</span>                              
                            </h4>
                        </div><!-- /postheader -->               
                        
                        <div class="share-this">                    
                            [removed][removed]
                        </div>
                        
                        {article-body}
                        
                    {/exp:weblog:entries}  
                    
                {/if}            
                {if logged_out}  
                            
                    {exp:weblog:entries weblog="equine-news" limit="1" status="Announcement|Open" disable="member_data|pagination" }                    
                        
                        <div class="postheader clearfix">
                            <span class="date"><strong>{entry_date format="%M"}</strong>{entry_date format="%j"} <small>{entry_date format="%Y"}</small></span>
                            <h3 class="title-post"><a href="http://{title_permalink=">{exp:xml_encode}{title}{/exp:xml_encode}</a></h3>
                            <h4 class="author-post clearfix">               
                                <span class="trans-none floatleft">By </span>
                                <span class="floatleft">{author} </span>
                                <span class="trans-none floatleft"> | Category(s):</span>
                                <span class="categories floatleft">{categories show="not 6" limit="2"}<a href="http://{path=">{category_name}</a> <br>{/categories}</span>                              
                            </h4>
                        </div><!-- /postheader -->               
                        
                        <div class="share-this">                    
                            [removed][removed]
                        </div>
                        
                        {article-body}
                        
                    {/exp:weblog:entries}
                    
                 {/if}          
               
                </div><!-- /content entry -->            
            </div><!-- /grid_8 -->       
        </div><!--/container_12 -->      
    </div><!-- /midcontent -->
    <!--   End middlecontent   --> 
    
    {embed="includes/footer-html"}
    
    {embed="includes/footer-scripts-subpg"}
    
    </body>
    </html>

    You could use those simple conditionals yeah but they also cover regular members being logged in. If you don’t have a membership site and are only limited to SuperAdmins then yes these tags will be fine

    That’s correct, no user membership, but I’ll word it the same as the article conditional and refer to a membership id.

    Thanks
    Jules

  • #10 / Feb 14, 2011 4:12pm

    JulesWebb

    271 posts

    I added the code below to the top of the page, but it still didn’t work.  So do I need to add a similar conditional stmt to each weblog:entries tag in order for it to work? There are a couple more - I have comments on the page, but due to character limitations I removed the code from the previous example.

    {if logged_in_group_id == 1 || logged_in_group_id == 6  } 
    
    <!-- =========================================================== -->    
    <!-- !        ARTICLES LISTED IF SUPER ADMIN OR MANAGER          -->
    <!-- =========================================================== --> 
    
        {exp:weblog:entries weblog="equine-news" limit="1" disable="member_data|comments|trackbacks|pagination" status="Announcement|Open|Draft" status="not Closed" require_entry="yes" url_title="{segment_3}"}
        {if no_results}{redirect="site/404"}{/if}
        {embed="includes/DOC-head" url_title="{segment_3}" 
            title_prefix=""
            title_suffix="{categories show="not 6" backspace="1" limit="2"}{category_name} |{/categories}" 
            hide_site_title="n"
         }
        {/exp:weblog:entries}
    
    {/if}            
    {if logged_out}
    
        {exp:weblog:entries weblog="equine-news" limit="1" disable="member_data|comments|trackbacks|pagination" status="open|Announcement" require_entry="yes" url_title="{segment_3}"}
        {if no_results}{redirect="site/404"}{/if}
        {embed="includes/DOC-head" url_title="{segment_3}" 
            title_prefix=""
            title_suffix="{categories show="not 6" backspace="1" limit="2"}{category_name} |{/categories}" 
            hide_site_title="n"
         }
        {/exp:weblog:entries}
    
    {/if}
  • #11 / Feb 15, 2011 8:55am

    Sue Crocker

    26054 posts

    Hi, WebbDiva.. You still have two status= sections in your template.

    Are you testing this with a url_title in segment_3?

  • #12 / Feb 19, 2011 12:57am

    JulesWebb

    271 posts

    You still have two status= sections in your template.

    I completely removed all other exp:weblog:entries tags (besides the one in question and the one bringing in the article) and I still get redirected to the 404 page

    Are you testing this with a url_title in segment_3?

    yes


    I can get it to work if I remove the conditional statement from the top and just use status=“Announcement|Open|Draft” status=“not Closed”:

    {exp:weblog:entries weblog="equine-news" limit="1" disable="member_data|comments|trackbacks|pagination" status="Announcement|Open|Draft" status="not Closed" require_entry="yes" url_title="{segment_3}"}
    {if no_results}{redirect="site/404"}{/if}
    {embed="includes/DOC-head" url_title="{segment_3}" 
        title_prefix=""
        title_suffix="{categories show="not 6" backspace="1" limit="2"}{category_name} |{/categories}" 
        hide_site_title="n"
     }
    {/exp:weblog:entries}

    BUT then if I’m not logged in and go to that page it loads everything but the article which isn’t really what I’m looking for.

    I can’t figure out why the conditional stmt works on the article section, but not when I use it at the top of the page.

    Any ideas or suggestions?

  • #13 / Feb 20, 2011 3:41pm

    Greg Salt

    3988 posts

    Hi WebbDiva,

    The issue is that the embed within the weblog:entries isn’t displaying anything when it is surrounded by the if logged_in_member_group tags but it is when those are removed? Please post the contents of the embed.

    Cheers

    Greg

  • #14 / Feb 20, 2011 4:39pm

    JulesWebb

    271 posts

    Hi Greg

    I posted the info you requested below.  Since you pointed out

    The issue is that the embed within the weblog:entries isn’t displaying anything when it is surrounded by the if logged_in_member_group tags but it is when those are removed?

    I went ahead and tested to see if the conditional stmt would work if I removed {exp:lg_better_meta_pl:template} or {exp:sl_combinator:combine_css disable="no" debug="no"}

    It didn’t matter if either one or both was removed.

    {embed="includes/DOC-head" url_title="{segment_3}" 
        title_prefix=""
        title_suffix="{categories show="not 6" backspace="1" limit="2"}{category_name} |{/categories}" 
        hide_site_title="n"
     }

    Above is the embed call and below is the contents of that embed

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html >
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    {exp:lg_better_meta_pl:template}
    
    <meta http-equiv="Content-Style-Type" content="text/css"/>
    <meta http-equiv="Content-Script-Type" content="type"/>
    
    {exp:sl_combinator:combine_css disable="yes" debug="no"}
    <link rel="stylesheet" type="text/css" media="screen,projection" href="/memanager/templates/css/reset.css" />
    <link rel="stylesheet" type="text/css" media="screen,projection" href="/memanager/templates/css/960.css" />
    <link rel="stylesheet" type="text/css" media="screen,projection" href="/memanager/templates/css/style.css" />
    <link rel="stylesheet" type="text/css" media="screen,projection" href="/memanager/templates/css/validationEngine.jquery.css" />
    <link rel="stylesheet" type="text/css" media="screen,projection" href="/memanager/templates/css/jquery.fancybox-1.3.0.css" />
    {/exp:sl_combinator:combine_css}
    
    <link rel="stylesheet" type="text/css" media="print" href="/memanager/templates/css/print.css" />
    
    <link rel="alternate" type="application/rss+xml" title="Meddleton Equine News" href="http://feeds.feedburner.com/MeddletonEquineHospital" />
    
    <meta name="google-site-verification" content="tywnDgFWPhDfHK3KX8DWUhRZ_ICuSERZJ4UsCnjfuoU" />   
    
    <link rel="icon" href="http://www.meddletonequine.com/favicon.ico"/>
    <link rel="shortcut icon" href="http://www.meddletonequine.com/favicon.ico" />
       
    </head>
  • #15 / Feb 21, 2011 9:33am

    Sue Crocker

    26054 posts

    Hi, WebbDiva. I’d do the following:

    Drastically reduce your template to *just* the if logged in info - forget the embeds, etc. Does that work?

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

ExpressionEngine News!

#eecms, #events, #releases