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]
  • #46 / Mar 22, 2011 2:23am

    JulesWebb

    271 posts

    Viewing the article if the status is draft and the logged in user is from group 1 or 6 is not a problem. 

    Getting the page to redirect to the 404 page if the status is draft and the logged in user is not ID 1 or 6 is the issue. 

    With this in mind I’d like to try a new approach. 
    Is it possible to use status in an if statement?  See code below.
    I did test this and it threw an error, but I thought you might confirm if it’s possible.  I might just have the syntax incorrect.

    Thanks
    Jules

    {if logged_in_group_id != 1 || logged_in_group_id != 6 && status="Draft" }
    
        {redirect="site/404"}
    
    {/if}
  • #47 / Mar 22, 2011 1:28pm

    Lisa Wess

    20502 posts

    Yes, status is available to conditionals.  Did you try your conditional there in the template?

    Just to add, you might consider using a dedicated “preview” template and live look; you can then access restrict that template to the appropriate groups and redirect to a 404 if no access.  This lets EE do the hard work, no conditionals required. =)

  • #48 / Mar 22, 2011 4:21pm

    JulesWebb

    271 posts

    Yes, status is available to conditionals.  Did you try your conditional there in the template?

    I did test this and it threw an error, but I thought you might confirm if it’s possible.  I might just have the syntax incorrect.

     

    I did test it, but I figure I got the wrong syntax.  I couldn’t find an example of it in the docs or forum.  searching “if status =” mostly returns Channel Entries Tag Parameters.  I’m hoping you can set me straight or provide an informative link

     

    you might consider using a dedicated “preview” template and live look; you can then access restrict that template to the appropriate groups and redirect to a 404 if no access.  This lets EE do the hard work, no conditionals required. =)

    I never could figure out how Live Look worked.  The url the link provides is messed up (see below)
    http://www.meddletonequine.com/?URL=http://www.meddletonequine.com/equine-news/read/50/

    This is how I understand it:
    create template in my “equine-news” template group - call it “preview”
    set preferences so only member groups I want can access template
    select Live Look Template template (in channel section preferences under Path Settings)
    What I don’t understand is how to effect the url that it produces

    If I can get this to work that would be great.

    Appreciate the continued help! 😊

    Jules

  • #49 / Mar 23, 2011 9:31am

    John Henry Donovan

    12339 posts

    WebbDiva,

    I did test it, but I figure I got the wrong syntax.  I couldn’t find an example of it in the docs or forum.  searching “if status =” mostly returns Channel Entries Tag Parameters.  I’m hoping you can set me straight or provide an informative link

    You are using it correctly but the syntax is incorrect. Take a look here for comparison syntax

    {if logged_in_group_id != 1 || logged_in_group_id != 6 && status == "Draft" }

    I never could figure out how Live Look worked.  The url the link provides is messed up (see below)
    http://www.meddletonequine.com/?URL=http://www.meddletonequine.com/equine-news/read/50/

    That looks correct. It does seeing as your are removing the index.php anyways. It goes to right place after clicking?

    This is how I understand it:
    create template in my “equine-news” template group - call it “preview”
    set preferences so only member groups I want can access template
    select Live Look Template template (in channel section preferences under Path Settings)
    What I don’t understand is how to effect the url that it produces

    That all looks fine. The one thing I would add to your exp:weblog:entries status parameter is Closed though so it shows you the entry even though it is closed.

    What isn’t working here specifically?

  • #50 / Mar 23, 2011 7:44pm

    JulesWebb

    271 posts

    You are using it correctly but the syntax is incorrect. Take a look here for comparison syntax

    I see I missed the double “=”  I know better than this, thanks for pointing it out.  😛
    It now works just as it’s suppose to.  Oh, and I also appreciate you pointing out adding the status perameter “Closed” I hadn’t thought of that.


    RE: Live Look

    That looks correct. It does seeing as your are removing the index.php anyways. It goes to right place after clicking?

    This is the url that it goes to. 
    http://www.meddletonequine.com/?URL=http://www.meddletonequine.com/equine-news/preview/87/

    Seems correct, but I get the following error:

    Forbidden
    You don’t have permission to access / on this server.
    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    Apache mod_fcgid/2.3.6 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at http://www.meddletonequine.com Port 80

    I set up access on the template to “all” thinking that could be part of the problem, but it didn’t make any difference. 

    What am I missing?

    REALLY appreciate you guys sticking with me on this MEGA thread :cheese:

    Jules

  • #51 / Mar 24, 2011 1:50am

    JulesWebb

    271 posts

    Hi John

    I had a chance to test out the status conditional and just couldn’t get it to work.  I stripped it down to just

    {if status == "Draft" } 
        {redirect="site/404"}
    {/if

    and it still doesn't work. I tested with just the logged in groups and that did work

    {if logged_in_group_id != 1 || logged_in_group_id != 6 }  
        {redirect="site/404"}
    {/if

    Am I missing something?

    Jules

  • #52 / Mar 24, 2011 3:59pm

    Sue Crocker

    26054 posts

    Jules, is there a possibility it has to do with your .htaccess again? Remember how you had to modify it to get the ellislab folder to work?

  • #53 / Mar 24, 2011 4:17pm

    JulesWebb

    271 posts

    Hi Sue

    I actually tested it on my live page. —I don’t see how the .htaccess page could be effecting it.

  • #54 / Mar 25, 2011 9:46am

    Sue Crocker

    26054 posts

    It’s something to do with what is in the preview template. I created a new template called preview2 and just put in some text, so *that* works. But the redirect still gives me an error, but if I manually type in the link it works.

    Are your content editors going to be using a preview template?

  • #55 / Mar 25, 2011 7:57pm

    JulesWebb

    271 posts

    It’s something to do with what is in the preview template. I created a new template called preview2 and just put in some text, so *that* works. But the redirect still gives me an error, but if I manually type in the link it works.

    I modified my preview template so it’s the same as the “read” template except for using all the statuses, and show_future_entries=“yes” This works as long as I use the url title not the ID

    this works: http://www.meddletonequine.com/equine-news/preview/vesicular-stomatitis-in-new-mexico/
    page ID does not: http://www.meddletonequine.com/equine-news/preview/79/

    I’m OK with this.  I’m curious though how you got the live look to go to “preview2”—Where is this setting located?  I also tried the live look and replacing the article ID with the URL title, I got the same error.

    Are your content editors going to be using a preview template?

    This is actually my brother’s site and I’ve been managing it for him. I just need to make it so I can send him preview links to review.  He was my guinea pig for my first EE site :cheese:

    I think we can wrap this thread up.  I’m happy with this solution, and I appreciate you guys sticking with me.  If you could just answer my question above about how you changed the live look setting I think we can close this thread.

    Thank you SO much!
    Jules

  • #56 / Mar 27, 2011 3:55pm

    Greg Salt

    3988 posts

    Hi Jules,

    The Live Look Template setting is in the Weblog Preferences Path settings at Admin > Weblog Administration > Weblog Management > Edit Weblog Preferences.

    Cheers

    Greg

  • #57 / Mar 27, 2011 4:18pm

    JulesWebb

    271 posts

    The Live Look Template setting is in the Weblog Preferences Path settings at Admin > Weblog Administration > Weblog Management > Edit Weblog Preferences.

    ..oh yeah, now I remember.  Thanks.

    Jules
    PS
    You can close the thread now.  Thanks for sticking with me 😝

  • #58 / Mar 28, 2011 10:01am

    Sue Crocker

    26054 posts

    Whew… that was a long thread. 😊 Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases