Forums / Setup & design / Users can read intro but not message body

Users can read intro but not message body

Author Message

James Ward

Tuesday 29 April 2003 12:13:31 pm

I wish to setup a site where anonymous users can see all the article titles and their intros but can not view the article body until they are logged in. I am switching from ez2.2.x to ez3 to attempt this.

I understand how to allow or deny users access to various classes but I see no way to seperate access to intros from access to the article bodies. Any help would be much appreciated.

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

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

eZ debug

Timing: Jan 18 2025 01:57:20
Script start
Timing: Jan 18 2025 01:57:20
Module start 'content'
Timing: Jan 18 2025 01:57:21
Module end 'content'
Timing: Jan 18 2025 01:57:21
Script end

Main resources:

Total runtime1.0723 sec
Peak memory usage4,096.0000 KB
Database Queries200

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0070 589.4766180.8125
Module start 'content' 0.00700.9237 770.2891576.2500
Module end 'content' 0.93070.1415 1,346.5391337.3672
Script end 1.0722  1,683.9063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00490.4536210.0002
Check MTime0.00210.1963210.0001
Mysql Total
Database connection0.00090.080410.0009
Mysqli_queries0.978891.27532000.0049
Looping result0.00250.23641980.0000
Template Total1.034796.520.5174
Template load0.00210.194520.0010
Template processing1.032696.295320.5163
Template load and register function0.00020.015410.0002
states
state_id_array0.00130.118110.0013
state_identifier_array0.00180.172220.0009
Override
Cache load0.00180.1668440.0000
Sytem overhead
Fetch class attribute can translate value0.00160.145630.0005
Fetch class attribute name0.00110.103170.0002
XML
Image XML parsing0.00250.236030.0008
class_abstraction
Instantiating content class attribute0.00000.0020100.0000
General
dbfile0.00930.8670340.0003
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 28
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs