Share » Forums » Setup & design » Users can read intro but not message...

Users can read intro but not message body

Users can read intro but not message body

Tuesday 29 April 2003 12:13:31 pm - 4 replies

Author Message

Paul Borgermans

Thursday 01 May 2003 1:38:07 am

There is no built in access control (roles) for attributes, but you may achieve this in the templates.

If you want this for all articles, edit (or create) an override template for your article template for full views. In this you make use of the fetch function for obtaining user info and act accordingly, for example in the demo setup, change :

{attribute_view_gui attribute=$content_version.data_map.body}

to

{let thisuser=fetch('user','current_user')}
{section show=$thisuser.is_logged_in}
{attribute_view_gui attribute=$content_version.data_map.body}
{section-else}
You need to <a href={'/user/login'|ezurl}>login</a> to see this sexy body
{/section}
{/let}

If you have a mix of public and semi-private articles, then copy the article class to a new one and use the override templates for this new class as shown above.

hth

Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

James Ward

Thursday 01 May 2003 8:05:50 pm

Works like a charm Paul. This is a great feature for sites which will want to charge for access to some but not all of their content.

Many thanks,
James

working at www.wardnet.com
blogging at www.jamesward.ca

James Ward

Thursday 01 May 2003 9:07:45 pm

I would like to add the actual login form to the
{section-else}

{/section}
portion of the example given by Paul. It's always nice to save our users an extra click where possible. :)

Anyone know where I can find the code to open the login form? It's not a class and it's not a section so I'm a little lost. Thanks for any help.

working at www.wardnet.com
blogging at www.jamesward.ca

James Ward

Thursday 01 May 2003 9:34:40 pm

I seem to have figured it out. The following appears to work:

{section-else}
You need to login to see the body of this document.<br />
{include uri="design:user/login.tpl"}
{/section}

Obviously the key being the {include uri="design:user/login.tpl"} line.

It's amazing what you can do once you understand how this templating engine works. :)
Thanks for all your help.

working at www.wardnet.com
blogging at www.jamesward.ca

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu