Share » Forums » Setup & design » Howto create a "really" personalized...

Howto create a "really" personalized input form

Howto create a "really" personalized input form

Friday 30 December 2005 5:53:43 pm - 11 replies

Author Message

Federico Canuti

Saturday 31 December 2005 3:51:26 am

Also to create an input form I often find {attribute_edit_gui attribute=$object.data_map.message} or a similar code, How can I have access to the attribute_edit_gui function to modify (possibly with an override) the way it works?

Esteban Rodriguez

Saturday 31 December 2005 5:41:59 am

Hi Federico,

attribute_edit_gui uses the templates you will find in:
design/standard/templates/content/datatype/edit
One template for each datatype. You can override these by copying them at the same path on the design dir of your site, ie.
design/_YOURSITE_/templates/content/datatype/edit

You could also create the form hardcoding each attribute in the edit template, instead of using a loop, though I would advice against it.

hope it helps,

Esteban

I have great faith in fools; self-confidence my friends call it.

http://presencia.net

Federico Canuti

Saturday 31 December 2005 8:21:55 am

Great thanks, not really intuitive but after al little tweaking it works!

Federico Canuti

Wednesday 11 January 2006 9:12:35 am

I have to "bump" because my code sometimes works and sometimes not, and I'm really screwed about the same code working only under certain condition (that I haven't identified).
Basically sometimes the parameter is passed correctly, sometimes not.

This is in my template:
{let parametro=hash(1,'titolo', 2, 'testo')}
<label for="titolo">{'Titolo'|i18n('design/base')}</label>
{attribute_edit_gui attribute=$object.data_map.subject parameter=$parametro}

<label for="testo">{'Testo'|i18n('design/base')}</testo>
{attribute_edit_gui attribute=$object.data_map.message parameter=$parametro}

and in ezstring.tpl (used by attribute_edit_gui):
id="{$parameter.1}" inside the <input ....> tag

in eztext.tpl: id="{$parameter.2}"

This code work correctly but when I go to the registration form:
{let parametro=hash(1, $ContentObjectAttribute:item.id, 2, $ContentObjectAttribute:item.id)}

<input type="hidden" name="ContentObjectAttribute_id[]" value="{$ContentObjectAttribute:item.id}" />

<label for="{$ContentObjectAttribute:item.id}"> ... </label>
{attribute_edit_gui attribute=$ContentObjectAttribute:item parameter=$parametro}

In this case I don't get the parameter passed to the other template, obviously I'm not referring to username and password that are identified with an "if" section and worked out in a different way, these are normal text line or text block attributes just like those (working) tha I writed above.
Any ideas? It is because I'm passing the content of a variable and not a string or an int?

Esteban Rodriguez

Wednesday 11 January 2006 11:49:38 am

Hi Federico,

I'm a bit at a loss as to why this doesn't work. My wild guess would be that you might have some issue with namespaces in your registration form template so the value for $parametro is not coming through? that's the first thing that comes to mind. It ought to work as far as I can see...

post the whole code, or some larger part of its context and I'll try to help you figure it out.

Esteban

I have great faith in fools; self-confidence my friends call it.

http://presencia.net

Federico Canuti

Thursday 12 January 2006 2:39:06 am

usually I don't post complete code because it is boring to read but... you asked ;)
It is an override of user/register.tpl, I kept the original code (3.6.0) and modified the appearance of what I need.

.....
<div class="contenuto">

<form enctype="multipart/form-data"  action={"/user/register/"|ezurl} method="post" name="Register">

<div class="maincontentheader">
<h2>{"Registrazione utente"|i18n("design/standard/user")}</h2>
</div>

{section show=$validation.processed}

{section name=UnvalidatedAttributes loop=$validation.attributes show=$validation.attributes}
<div class="warning">
<p><strong>{"Input non valido"|i18n("design/standard/user")}</strong></p>
<ul>
    <li>{$UnvalidatedAttributes:item.name}: {$UnvalidatedAttributes:item.description}</li>
</ul>
</div>
{section-else}
<div class="feedback">
<p><strong>{"I dati sono stati salvati correttamente"|i18n("design/standard/user")}>/strong></p>
</div>
{/section}

{/section}



{section show=count($content_attributes)|gt(0)}
    {section name=ContentObjectAttribute loop=$content_attributes sequence=array(bglight,bgdark)}

{if eq($ContentObjectAttribute:item.contentclass_attribute.name, 'Dettagli account')}
<fieldset>
<legend>{$ContentObjectAttribute:item.contentclass_attribute.name}</legend>
    {attribute_edit_gui attribute=$ContentObjectAttribute:item}
</fieldset>

{else}

{let parametro=hash(1, $ContentObjectAttribute:item.id, 2, $ContentObjectAttribute:item.id)}

    <input type="hidden" name="ContentObjectAttribute_id[]"  value="{$ContentObjectAttribute:item.id}" />
    <div class="block">
    <label for="{$ContentObjectAttribute:item.id}">{$ContentObjectAttribute:item.contentclass_attribute.name}</label><div class="labelbreak"></div>
    {attribute_edit_gui attribute=$ContentObjectAttribute:item parameter=$parametro}
    </div>

{/let}

{/if}

    {/section}

    <div class="buttonblock">
    <input class="button" type="submit" name="PublishButton" value="{'Invia i dati'|i18n('design/standard/user')}" />
    <input class="button" type="submit" name="CancelButton" value="{'Cancella'|i18n('design/standard/user')}" />
    </div>
{section-else}
<div class="warning">
<p><strong>{"Impossibile creare il nuovo utente"|i18n("design/standard/user")}</strong></p>
</div>
<input class="button" type="submit" name="CancelButton" value="{'Back'|i18n('design/standard/user')}" />
{/section}
</form>
</div>

Any hints?

Federico Canuti

Thursday 12 January 2006 3:11:23 am

To add a little bit of thrill, even this code (from the documentation) isn't working inside this template, as obvious I put the def at the beginning and set inside the loop but the value doesn't change.

{def $i=255}
{set $i=inc( $i )}
{$i}

Esteban Rodriguez

Thursday 12 January 2006 1:15:45 pm

Firstly, are you certain you're getting into the "else" part of your condition? here:

{section name=ContentObjectAttribute loop=$content_attributes sequence=array(bglight,bgdark)}

		{if eq($ContentObjectAttribute:item.contentclass_attribute.name, 'Dettagli account')}
			<fieldset>
				<legend>{$ContentObjectAttribute:item.contentclass_attribute.name}</legend>
			   {attribute_edit_gui attribute=$ContentObjectAttribute:item}
			</fieldset>
		{else}
			{let parametro=hash(1, $ContentObjectAttribute:item.id, 2, $ContentObjectAttribute:item.id)}

			<input type="hidden" name="ContentObjectAttribute_id[]" value="{$ContentObjectAttribute:item.id}" />
			<div class="block">
			<label for="{$ContentObjectAttribute:item.id}">{$ContentObjectAttribute:item.contentclass_attribute.name}</label><div class="labelbreak"></div>
			{attribute_edit_gui attribute=$ContentObjectAttribute:item parameter=$parametro}
			</div>
			{/let}
		{/if}
	{/section}

I know it sound silly, but one does sometimes overlook these things. You could do some "manual" debugging to see if it's actually getting in there.

If that's ok (which probably is), I would try using this

{attribute_edit_gui attribute=$ContentObjectAttribute:item parameter=$:parametro}

instead of this

{attribute_edit_gui attribute=$ContentObjectAttribute:item parameter=$parametro}

I never got this completely straight, but I've sometimes had trouble with namespaces in similar situations, and you seem to have something like that going with the increment code you posted last (I mean variable reference problems).

Tell me if trying along these lines solves anything. I'll try pasting your code on a site tonight and play with it a bit.

Later,

Esteban

I have great faith in fools; self-confidence my friends call it.

http://presencia.net

Federico Canuti

Thursday 12 January 2006 2:15:06 pm

It was " : " , thank you very much... now could tell me why it happens and what is this namespace problem? Just curious

Esteban Rodriguez

Thursday 12 January 2006 6:31:37 pm

Glad it worked! As a matter of fact, I don't have much of a clue as to why it works this way :-P

As far as I understand, when you set a name on a section (or some other function, such as set) you are setting a namespace (or scope, if you want).
For instance in your code:

{section name=ContentObjectAttribute loop=$content_attributes sequence=array(bglight,bgdark)}

you are defining the namespace "ContentObjectAttribute"

Then, when you set a value for $parametro, with a let inside this namespace, you are actually creating a variable inside this namespace (this variable makes no sense outside the scope of "ContentObjectAttribute") so, in order to reference $parametro, you actually need to specify it's the $parametro in the context "ContentObjectAttribute" and not some other, that would be $ContentObjectAttribute:parametro (you use someting similar to reference the id of the attribute in the input tag). $: is just short for "this namespace".

This is a very sloppy explanation, There's got to be better reading about this in the docs at ez.no, and probably something more about namespaces in wikipedia or something like it.

later,

Esteban

I have great faith in fools; self-confidence my friends call it.

http://presencia.net

Federico Canuti

Friday 13 January 2006 9:09:12 am

It remind me "this." from java, but I never saw it in the documentation.

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

36 542 Users on board!

Forums menu