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.

Custom Statuses

June 15, 2009 3:06pm

Subscribe [2]
  • #1 / Jun 15, 2009 3:06pm

    blukabm

    16 posts

    Please help me out here.

    My client needs to be able to lock certain articles down within the admin screens. So I created a custom status called “Locked”. They can now “lock” any article within that assigned blog.

    Here is my article page code:

    {exp:weblog:entries weblog="{this_template_group}" status="locked"}  
    <h1>{title}</h1>
    <strong>By {author}</strong>
    
    {entry_date format="%F %d, %Y - %g:%i:%s %A"}
    {summary} 
    {body}
    {extended}
    {/exp:weblog:entries}

    To test it, I set the “Locked” status as displaying to everyone but Black members. I logged in as a black member, but I can still see all this information. I tried removing the “...status=“locked”} in the code, but then it doesn’t display the locked article at all.

    Please help!

  • #2 / Jun 15, 2009 3:25pm

    Mark Bowen

    12637 posts

    I must admit I’m a little confused as to what you are trying to do here as you mentioned locking down articles within the admin screens but then you go on about template codes.

    You also mentioned that you had ‘locked down’ the status to everyone but the Black members. If I am understanding you correctly on this then what you have actually done is locked down permission for the Black members to actually post an entry using that status. If you then go and place on a template the code that you have shown above then anyone who has access to that template will see those posts with that status so you haven’t really locked it down by status at all.

    Were you referring to :

    Admin->Weblog Administration->Custom Entry Statuses->Add/Edit Statuses (Your Status Group)->Edit (Your Status)->Restrict status to members of specific groups

    If so then all this does is (as mentioned previously) prevent or allow member groups from posting an entry and using that particular status.

    I think there might be some slight misunderstanding as to what you are trying to do and the way in which you are going about it although I could be wrong as you have talked about a couple of different things above.

    Perhaps if you can give us more information as to what you are trying to do we will be able to help you out some more.

    Hope some of that helps a bit though.

    Best wishes,

    Mark

  • #3 / Jun 15, 2009 3:35pm

    blukabm

    16 posts

    Thanks for the quick response. Here is exactly what I’m trying to do:

    Some anonymous person goes to the site. They aren’t logged in or anything. They see the Heading and Summary of an article. They click “read more” and it asks them to login because that article is locked to members only. Basically they see the heading and summary as a “teaser”.

    I’m trying everything do figure this out. My goal here is to allow my client to pick and choose which articles to lock down without ever touching any code.

    Thanks so much

  • #4 / Jun 15, 2009 3:39pm

    Mark Bowen

    12637 posts

    Ah right I see what you’re trying to do now.

    The easiest way to do that is just like this :

    {exp:weblog:entries weblog="default_site"}
    <h2>{title}</h2>
    <p>{if logged_out}<br />
    {summary}<br />
    {/if}</p>
    
    <p>{if logged_in}<br />
    {body}<br />
    {/if}</p>
    
    <p>{/exp:weblog:entries}

    This would show just the title of the entry and the {summary} field to anyone who isn’t logged in and the title and the {body} field to anyone who is logged in. Does that help at all?

    Best wishes,

    Mark

  • #5 / Jun 15, 2009 3:45pm

    Mark Bowen

    12637 posts

    You might also want to take a look at this extension - Restrict Entries.

    Hope that helps a bit.

    Best wishes,

    Mark

  • #6 / Jun 15, 2009 3:59pm

    blukabm

    16 posts

    Hey Mark,

    So the only problem with that solution would be that it’s universal. There is nothing telling EE which article to apply that if statement to. It would do that no matter what the article being displayed is.

    What I need is a way for the client to say “This article is locked to members”. Then if a member goes to that article, it’s displayed.

    My current structure is as follows:

    Template Group
    2 files in the template group - index.php (lists article titles), article (shows the specific article chosen)

    Follow me?

  • #7 / Jun 15, 2009 4:11pm

    Mark Bowen

    12637 posts

    Well you can do what you want by using a status although you are only ever going to be able to apply one status to an entry so if you ever want an entry to be viewable by more than one member group what will you do then?

    If you do just want one member_group to be able to view an entry though then you can just do this sort of thing :

    {if member_group == "2" AND status == "locked"}
    Show information to this group only
    {if:else}
    Show alternate information here.
    {/if}

    Pretty sure that should do what you are after.

  • #8 / Jun 15, 2009 4:19pm

    blukabm

    16 posts

    See that’s why I thought the status would work. Because in the status, you can define which member groups are allowed to see it. But that’s what I was saying in my original post, it doesn’t work like that. And if I’m not mistaken, you can not use status in the if statement, can you? I attempted this and it was not working. That is why I had to form it like :

    {exp:weblog:entries weblog="{this_template_group}" status="locked"}
  • #9 / Jun 15, 2009 4:29pm

    Mark Bowen

    12637 posts

    See that’s why I thought the status would work. Because in the status, you can define which member groups are allowed to see it.

    No unfortunately as mentioned above when you allow access to statuses all that means is whether or not that member group can post an entry and use that status or not. You can use this to allow for a sort of custom publishing / editor process so say one member group can post entries but can’t make them go live as they for example don’t have access to the ‘live’ status.

    But that’s what I was saying in my original post, it doesn’t work like that. And if I’m not mistaken, you can not use status in the if statement, can you? I attempted this and it was not working. That is why I had to form it like :

    {exp:weblog:entries weblog="{this_template_group}" status="locked"}

    Sorry didn’t see that code in your original post and can’t see it there at the moment. Have you tried it as I showed just above. You can definitely use status in an {if} conditional like that provided you have it placed within the weblog tag. Perhaps give it a go and see how you go?

    Best wishes,

    Mark

  • #10 / Jun 15, 2009 4:30pm

    Mark Bowen

    12637 posts

    One other very small thing would be that you have weblog=“this_template_group” which doesn’t quite sound correct. Just check that you have the correct weblog name going into that parameter.

  • #11 / Jun 15, 2009 5:01pm

    blukabm

    16 posts

    the “this_template_group” is just a variable i’ve defined on the page. it works well. i’ll try your suggestions and let you know - thanks again for the advice!

  • #12 / Jun 15, 2009 5:07pm

    Mark Bowen

    12637 posts

    the “this_template_group” is just a variable i’ve defined on the page. it works well. i’ll try your suggestions and let you know - thanks again for the advice!

    Ah okay, no problems just thought it was a little oddly named seeing as how it is being used for the weblog parameter was expecting something a bit more like my_weblog_name 😉

    Hope it all goes well for you.

    Best wishes,

    Mark

  • #13 / Jun 16, 2009 10:31am

    blukabm

    16 posts

    So here is the relevant code:

    <h1>{exp:weblog:info weblog="{my_blog}"}{blog_title}{/exp:weblog:info}</h1>
    {exp:weblog:entries weblog="{this_template_group}" limit="5" paginate="bottom"}
    {if status == "locked"}
    <a href="http://{title_permalink={my_blog}/article}">(Members Only) {title}</a>
    {if:else}
    <a href="http://{title_permalink={my_blog}/article}">{title}</a>
    {/if}

    When you check the page out, it only lists the blog entries that do not have the status of “locked”. Even though I’ve clearly specified what to do with a “locked” status in the IF statement.

    Any ideas?

  • #14 / Jun 16, 2009 10:43am

    Mark Bowen

    12637 posts

    You’re missing the status=“locked” parameter on your weblog tag.

    <h1>{exp:weblog:info weblog="{my_blog}"}{blog_title}{/exp:weblog:info}</h1>
    {exp:weblog:entries weblog="{this_template_group}" limit="5" paginate="bottom" status="locked|open"}
    
    {if status == "locked"}
    <a href="http://{title_permalink={my_blog}/article}">(Members Only) {title}</a>
    {if:else}
    <a href="http://{title_permalink={my_blog}/article}">{title}</a>
    {/if}
    {/exp:weblog:entries}

    If you don’t place the status=“locked|open” parameter into your weblog tag then you will only ever pull back the entries which have a status of Open. If you add in the other status(es) into that parameter then the weblog tag will pull them back and then your conditional will fire.

    See if that works for you, should do 😊

    Best wishes,

    Mark

  • #15 / Jun 16, 2009 10:50am

    blukabm

    16 posts

    Hey that worked! Thanks so much! Ok so last question then, Is there a way to have my client define which member groups are able to see which articles using that status?

    When editing a status, I can clearly see the menu for “Restrict status to members of specific groups” - is that strictly for allowing someone to post? Not view?

    Any options you can think of to let the client choose which articles can be viewed without coding any templates? I’m fine doing any initial code, but just need to know if the client can then change the permissions later in EE.


    Thanks again!

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

ExpressionEngine News!

#eecms, #events, #releases