Extended body only for registered users?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
kobe
Posts: 4
Joined: Fri Jan 19, 2007 4:27 am

Extended body only for registered users?

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Extended body only for registered users?

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
kobe
Posts: 4
Joined: Fri Jan 19, 2007 4:27 am

Post 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
stm999999999
Regular
Posts: 1531
Joined: Tue Mar 07, 2006 11:25 pm
Location: Berlin, Germany
Contact:

Post by stm999999999 »

perhaps you are using another template with its own entries.tpl?
Ciao, Stephan
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply