Forums / Setup & design / Customising forms

Customising forms

Author Message

James Packham

Monday 12 January 2004 5:31:14 am

Hi I'm trying to create a form where anonymous users can only see some of the fields and not others. I think this means that I can't just use a normal edit_attribute.tpl because it'll just display all the attributes of the object.

Does this mean that I have to create a custom edit template with each of the attributes? Is there an easier/better way? It's just that if I add attributes to my object at a later date then I'll have to edit the template as well to make them visible for editing...

Thanks in advance,

~James~

Tore Skobba

Monday 12 January 2004 7:17:37 am

Hi

I had a somewhat similar problem, users should enter their data. However, only SOME of this data should be available for viewing by all users. As such I had this template code:

<ul class="attribute_list">
{section name=ContentObjectAttribute loop=$node.contentobject_version_object.contentobject_attributes}
{section show=$:item.contentclass_attribute.name|begins_with("Restricted")|not()}
<li> {$ContentObjectAttribute:item.contentclass_attribute.name|wash}:
{attribute_view_gui attribute=$ContentObjectAttribute:item}</li>
{/section}
{/section}
{/let}

Here ALL attributes begning with "Restricted" are not shown, you could the same in your edit template, simply allow editing of all attributes which does not begin with "Restricted" or whatever. For more see here:

http://www.ez.no/developer/ez_publish_3/documentation/customization/tips_tricks/hiding_attribute_content

James Packham

Monday 12 January 2004 1:58:07 pm

I don't fully understand - how do I add this to the exisiting edit_attribute.tpl? I tried

{section show=and(eq($ContentObjectAttribute:item.contentclass_attribute.can_translate,0),
ne($object.default_language,$ContentObjectAttribute:item.language_code)) |begins_with("Restricted")|not()) }

and

{section show=and(eq($ContentObjectAttribute:item.contentclass_attribute.can_translate,0),
ne($object.default_language,$ContentObjectAttribute:item.language_code),
ne($:item.contentclass_attribute.name|begins_with("Restricted")|not()) ) }

Among others, with and without the ; But none of them worked. Where do I need to put your wizzy bit of code?

Thanks,

~James~

James Packham

Wednesday 14 January 2004 1:55:26 am

Yay! I figured out how to do it. Incase anyone's interested you can add the following section statement to an override of edit_attribute.tpl (the code in the middle is already in edit_attribute). This uses the name of the attribute to filter out the attributes you don't want.

All you have to do then is add the word restricted to the begining of the identifier for the attributes you don't want.

{section show=$ContentObjectAttribute:item.contentclass_attribute_identifier|begins_with("restricted" )|not()}
<label>{$ContentObjectAttribute:item.contentclass_attribute.name|wash}</label><div class="labelbreak"></div>
<input type="hidden" name="ContentObjectAttribute_id[]" value="{$ContentObjectAttribute:item.id}" />
{attribute_edit_gui attribute_base=$attribute_base attribute=$ContentObjectAttribute:item}

{/section}

Also bear in mind that this code is repeated in a section-else (though I'm not sure why, something to do with a different set of conditions).

Thanks for your help :)

~James~

eZ debug

Timing: Jan 18 2025 22:10:59
Script start
Timing: Jan 18 2025 22:10:59
Module start 'content'
Timing: Jan 18 2025 22:10:59
Module end 'content'
Timing: Jan 18 2025 22:10:59
Script end

Main resources:

Total runtime0.2031 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0094 588.7266180.8438
Module start 'content' 0.00940.0078 769.570397.8359
Module end 'content' 0.01720.1858 867.4063526.1250
Script end 0.2030  1,393.5313 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00381.8516200.0002
Check MTime0.00140.6942200.0001
Mysql Total
Database connection0.00140.699310.0014
Mysqli_queries0.146472.12251410.0010
Looping result0.00150.72271390.0000
Template Total0.185391.310.1853
Template load0.00110.531910.0011
Template processing0.184290.718810.1842
Override
Cache load0.00070.329910.0007
Sytem overhead
Fetch class attribute can translate value0.00070.328410.0007
XML
Image XML parsing0.00030.150310.0003
General
dbfile0.00633.1002200.0003
String conversion0.00000.002830.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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs