Problem with form varibles in temaplte

Author Message

Jose Mourinho

Thursday 06 September 2007 12:40:22 pm

Hello all,

I want to ask if it isnessery to put specific name of componet of html forms in the template (
name of input bottons like <input type="submit" name="SomeSpecificName" value="Submit">)

The tempalte is override of full.tpl
One more thing: there is some cache and when i post the varible it is nessesry to clean the cache and refresh to see the chane.

the code of file is:
{*?template charset="utf-8"?*}
{set-block scope=root variable=cache_ttl}0{/set-block}

wanted_category post varible {ezhttp(
'wanted_category', 'post' )} <br />

<br />
{def $category_objects=fetch( content,
list,
hash( parent_node_id,
2167,) )}

<FORM action={concat( $node.url_alias,
'/(category)/', ezhttp( 'wanted_category', 'post' )
)|ezurl} method="post">
<select name="wanted_category" >
{foreach $category_objects as $category_object }
<option value
="{$category_object.contentobject_id}">{$category_object.name}</option>
{/foreach}
</select>
<INPUT type="submit" value="Send">
</FORM>
<p></p>
<br />
{if
and(is_set($view_parameters.category),ne($view_parameters.category,''))}
{def $query =fetch( content, list,
hash( parent_node_id,
2164,
attribute_filter, array(
array( 'hotel/category', '=',
$view_parameters.category ) ) ) )}
{else}
{def $query=fetch( content, list, hash(
parent_node_id, 2164 ) )}
{/if}

{foreach $query as $hotel }
<div style="border-style:dotted ">
<div style="display:inline;"> {attribute_view_gui
attribute=$hotel.data_map.imge image_class=small}
</div>
<div style="display:inline; margin-left:5em;">
{$hotel.data_map.name.content|wash( 'xhtml' )}
</div>

<div style="display:inline; ">
<a href={$hotel.url_alias|ezurl()}>link</a>
</div>
</div>
<br />

{/foreach}

10x of all

Atle Pedersen

Friday 07 September 2007 12:12:30 am

Hi,

I'm not sure, but it seems to me that your form and its names are correct, but that your logic is slightly flawed.

The first time you load a page with this code, the category variable will not be set. This leads to an incomplete action in your form. That means that the first time a user uses the send button, the category variable will be empty.

After the first press wanted_category is set, and using the send button from now on will also set the category variable.

If this is not the problem, that is you that the first time you enter the page the category variable already set, then try writing out some variables and specify exactly what it is that is not working.

Atle

Jose Mourinho

Friday 07 September 2007 5:18:06 am

Hi Atle Pedersen

The logic is that when first time user comes in the page no categoy should be set and user will see all hotels. If user set a cetegoy by the form the page must show only the hotels that belongs in this category.

This is the logic ...

Atle Pedersen

Friday 07 September 2007 11:35:11 am

Well, then you need only one variable. At the moment you're trying to use two, and this makes no sense.

My advice would be to only use the post variable wanted_category, remove (category) and do your fetch based on wanted_category.

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