Page 1 of 1

Extended body only for registered users?

Posted: Sun Jul 29, 2007 11:51 am
by kobe
Hi everybody,

I would like to have the "Entry Body" that can be read by everyone, while only registered users should be able to read the "extended body". I was wondering whether this is possible or not. If not and if it would not be to complicated, could anyone create a plug-in?

Thanks in advance,

Kobe

Re: Extended body only for registered users?

Posted: Sat Aug 04, 2007 3:46 pm
by garvinhicking
Hi!

You can do that by password-protecting an entry. Check out the plugin "Extended options for entries", then you can set a password for individual entries.

You could also patch this by editing the entries.tpl smarty file and add a

Code: Select all

{if $is_logged_in}
{$entry.extended}
{else}
You must be logged in to read this!
{/if}
in the place where you usually show your entry body...

Best regards,
Garvin

Posted: Sun Aug 05, 2007 1:20 pm
by kobe
Hi Garvin, thanks for you answer, it's clear but I still need some help! I'd prefer to use the 2nd option, meaning that I've modified the /templates/default/entries.tcl file from this:

Code: Select all

{if $entry.is_extended}
            <div class="serendipity_entry_extended">
                        <a id="extended"></a>
                        {$entry.extended}
            </div>
{/if}
into this:

Code: Select all

{if $entry.is_extended}
            <div class="serendipity_entry_extended">
                        <a id="extended"></a>
                        {if $is_logged_in}
                                    {$entry.extended}
                        {else}
                                    You must be logged in to read this!
                        {/if}
            </div>
{/if}
but I suppose I'm doing something wrong since it doesn't show the error message when I try to read the extended body (when I'm not logged in) :(

I have an additional question for you: how are the categories variables called? Cause I'd like to change the if string in something like that:

Code: Select all

{if $is_logged_in || "category name"=="category News"}
            {$entry.extended}
{else}
            You must be logged in to read this!
{/if}
Meaning that for the category "News" this restriction is not on. Would this be possible?

Thanks a lot!

Regards,

Kobe

Posted: Sun Aug 05, 2007 1:24 pm
by stm999999999
perhaps you are using another template with its own entries.tpl?

Posted: Mon Aug 06, 2007 11:03 am
by garvinhicking
Hi!

Yes, stm9x9s idea comes to my mind as well. Try to change something else in the entries.tpl file and see if it works for you?

Do you see the link "Edit entry" in the article footer when you view it? This is an indicator that tells you that you ARE logged in!

Your second IF-problem is a bit harder, because entries can be assigned to multiple categories. You need to check the $entry.categories array with a foreach loop, assign a variable if your category is found, and then check that variable. I can't tell you that frmo the top of my head, so you might need to check out the Smarty documentation for that.

An easier way would be to install the 'Extended properties for entries' plugin and make use of custom entryproperty fields. Just create a "unprotected" variable, and for the entries you don'T want to protect, you set that field to "1". In your template file you can then use:

Code: Select all

{if $is_logged_in OR $entry.properties.ep_unprotected == 1}
...
Regards,
Garvin