Forums / Setup & design / ezhttp get problem

ezhttp get problem

Author Message

Arran Price

Thursday 03 February 2005 5:26:14 pm

Hi,
Ive been struggling with this. According to the documentation I should be able to use ezhttp to grab the variables passed via get or put.
The documentation at
http://www.ez.no/ez_publish/documentation/reference/template_operators/data_extraction/ezhttp
shows the syntax, but its not working for me. Even more bizzare is that the results are sometimes shown correctly, but I havent been able to determine why it works sometimes and not others. Im using 3.4.4

The code below should have a text field and drop down menu/selection from my custom class. It should use get to pass the vars back to itself which Im using in my fetch to return the correct results. I can see the url itself does have the parameters in it eg:
http://www.somesite.com/index.php/intranet/our_resources/intranet/phone_list?searchname=Bob&searchdepartment=0&searchbutton.x=7&searchbutton.y=7

{let  search_name=ezhttp('searchname','get')
   search_department=ezhttp('searchdepartment','get')
}
   {* SEARCH FIELDS *}
   
            {* NAME ENTRY FIELD *}
      <form action="/index.php/intranet/our_resources/intranet/phone_list" method="get">
            <p>Name</p>
            <input id="searchname" type="text" name="searchname" size="22" maxlength="24"/>
   	      <input type="image" border=0 name="searchbutton" src={"/images/top_nav/search_button.gif"|ezdesign}>
      
         {* DEPARTMENT SELECTION *}
         {set department_list_array=fetch( 'content', 'class_attribute', hash( 'attribute_id', 263 ) )}
         <div class="element">
            <label>Department</label><div class="labelbreak"></div>
            <select name="searchdepartment">
               <option value="-1">Any Department</option>
               
               {section loop=$department_list_array.content.options }
                  <option value="{$department_list_array.content.options.$index.id}"> {$department_list_array.content.options.$index.name} </option>
               {/section}
            </select>
            
         </div>
      </form>
   
   
   <hr>
   <p>search_name={$search_name}</p>
   <p>search_department={$search_department}.</p>
   
{/let}   

the syntax being used with ezhttp is just one version Ive tried. Ive also tried without the single qoutes and also using first_set (just because there was an example of setting a variable in a post that someone had confirmed working).

Yet again its bound to be something stupid Im doing, but I cant see what.
Or is just bad karma to pass vars back to the same template in this manner?

Any help greatly appreciated.

Arran

Arran Price

Sunday 06 February 2005 11:39:21 am

I figured I would test to see if the issue was due to passing params to itself, by making it pass to a different template that just displays the vars eg:

{let  search_name=ezhttp('searchname','get')
   search_department=ezhttp('searchdepartment','get')
}
   <h1>Results Test</h1>
   <p>search_name={$search_name}</p>
   <p>search_department={$search_department}.</p>
   
{/let}   

The vars get passed the first time, but then every other time I use the first template to plug in the parameters it displays as the ones passed the first time in the second template.

Anybody able to throw me a lifeline?
This is the last hurdle I have for a fairly major application.

Arran

Łukasz Serwatka

Sunday 06 February 2005 12:01:56 pm

Hi,

This is because you have cache enabled. You can disable cache for this tpl file.

Put this at the first line in your tpl file.

{set-block scope=root variable=cache_ttl}0{/set-block}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Arran Price

Sunday 06 February 2005 12:30:39 pm

Many thanks Luke.
Just like that, its now working.

cheers

Arran

Łukasz Serwatka

Sunday 06 February 2005 12:56:02 pm

Hi,

Great. You don`t have to disable cache if you use accessing variables via URL like this
.../(lang)/en

so the variable is lang and has value en

{$view_parameters.lang} -> displays value

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Arran Price

Sunday 06 February 2005 1:19:17 pm

Thanks, I have view_parameters working already for other parts of the app.
When I need the user to enter in something in say a text field I have to use either post or get though dont I?
Or is there a way to use it with a view_parameter?

Arran

Eivind Marienborg

Sunday 06 February 2005 8:03:54 pm

I'm trying to get the ezhttp to work in an edit template, without any luck.

This is the code that launches the edit template:

       <form method="post" action={"content/action"|ezurl}>

        <input type="hidden" name="ContentNodeID" value="{$:item.object.owner.main_node_id}" />
        <input type="hidden" name="ContentObjectID" value="{$:item.object.owner.id}" />
        <input type="hidden" name="ViewMode" value="full" />
        <input type="hidden" name="privat" value="{$:item.object.data_map.privat.data_int}">

        <input type="hidden" name="NodeID" value="{$:item.object.owner.main_node_id}" />
        <input type="hidden" name="ClassID" value="47">
        <input type="image" name="NewButton" value="svar" src="/share/icons/reply.gif" alt="Svar!" title="Svar!">
        </form>

The variable I'm trying to pick up, is "privat".

This is the code in the edit template (for testing purposes as of now..):

{let privat2=ezhttp('privat','get')}
        <!-- Privat2: {$privat2} -->
{/let}

This code returns nothing.

Having debug enabled, I get the error message "Unknown get variable 'privat'". Am I doing anything wrong, or is it just impossible to use ezhttp in edit templates?

Arran Price

Monday 07 February 2005 4:15:20 pm

I think your issue is that you are trying to read the variable from a get:

ezhttp('privat','get')}

but your form does a post

form method="post"

If you change both instances to either get or post you might have more luck.

Arran