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~

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 00:17:56
Script start
Timing: Jan 19 2025 00:17:56
Module start 'layout'
Timing: Jan 19 2025 00:17:56
Module start 'content'
Timing: Jan 19 2025 00:17:57
Module end 'content'
Timing: Jan 19 2025 00:17:57
Script end

Main resources:

Total runtime0.6317 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0063 588.9297152.6094
Module start 'layout' 0.00630.0030 741.539139.4141
Module start 'content' 0.00930.6209 780.9531524.5078
Module end 'content' 0.63020.0015 1,305.460912.1875
Script end 0.6317  1,317.6484 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00310.4928160.0002
Check MTime0.00130.2064160.0001
Mysql Total
Database connection0.00070.117510.0007
Mysqli_queries0.573790.8164600.0096
Looping result0.00050.0808580.0000
Template Total0.603095.520.3015
Template load0.00210.324720.0010
Template processing0.601095.131620.3005
Template load and register function0.00010.016110.0001
states
state_id_array0.00090.135010.0009
state_identifier_array0.00060.099920.0003
Override
Cache load0.00180.2834450.0000
Sytem overhead
Fetch class attribute can translate value0.00050.085320.0003
Fetch class attribute name0.00080.121450.0002
XML
Image XML parsing0.00050.080620.0003
class_abstraction
Instantiating content class attribute0.00000.002670.0000
General
dbfile0.00090.1487160.0001
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs