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

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 18 2025 19:10:06
Script start
Timing: Jan 18 2025 19:10:06
Module start 'layout'
Timing: Jan 18 2025 19:10:06
Module start 'content'
Timing: Jan 18 2025 19:10:06
Module end 'content'
Timing: Jan 18 2025 19:10:06
Script end

Main resources:

Total runtime0.9454 sec
Peak memory usage4,096.0000 KB
Database Queries74

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0081 589.3203152.6094
Module start 'layout' 0.00810.0029 741.929739.4141
Module start 'content' 0.01100.9327 781.3438657.2734
Module end 'content' 0.94370.0017 1,438.617220.1875
Script end 0.9453  1,458.8047 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3524160.0002
Check MTime0.00140.1430160.0001
Mysql Total
Database connection0.00230.248210.0023
Mysqli_queries0.861391.1030740.0116
Looping result0.00070.0762720.0000
Template Total0.910896.320.4554
Template load0.00250.263520.0012
Template processing0.908396.078220.4542
Template load and register function0.00020.024110.0002
states
state_id_array0.00120.126210.0012
state_identifier_array0.00140.149720.0007
Override
Cache load0.00210.2228630.0000
Sytem overhead
Fetch class attribute can translate value0.00090.091330.0003
Fetch class attribute name0.00140.1533100.0001
XML
Image XML parsing0.00130.137130.0004
class_abstraction
Instantiating content class attribute0.00000.0024110.0000
General
dbfile0.00180.1903240.0001
String conversion0.00000.001040.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
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
7content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 45
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs