HTTP POST & GET Hack (instead of ezenv)

Author Message

Willie Seabrook

Sunday 02 November 2003 11:39:00 pm

Hi all,

Here's a very simple hack that I'm using to enable the use of HTTP GET and POST variables within templates. I found that while ezenv was just usable, it had a number of shortcomings - most notably the inability to handle array values.

So simply go to /kernel/content/view.php and at *approx* line 220 where variables like view_parameters etc are set add the following lines:

$tpl->setVariable( 'post', $_POST, 'Parameters' );
$tpl->setVariable( 'get', $_GET, 'Parameters' );

Now in all your templates you will be able to access any variable with something like

{$Parameters.post.variableName} and
{$Parameters.get.variableName} if your form used the HTTP GET method.

It works fine with arrays also, so if you need to submit a form with an array you can access

{$Parameters.post.variableName.0}
{$Parameters.post.variableName.1}
etc etc

just fine.

I needed this functionality for a search feature that I had to build. I needed to search a certain content class based upon multiple parameters and along with this I also made another fetch function that allowed me to do detailed searches of instances of a specific content class. I had to implement a new fetch function because the list search by attributes still doesn't work properly and even if it did its features aren't full enough.

My solution is a slow hack but it works and thats fine. If anyone is interested in a little overview on how to create a new fetch function and work with content objects in php (quite a hard hacky thing to do) I'll post my code and docs.

Regards,
Willie Seabrook

Alex Jones

Monday 03 November 2003 7:03:12 am

That's great Willie! I would love to see you add an overview of this as a contribution. I mayvery well try it on my next eZ pub site.

Thanks for posting about htis,

Alex

Alex
[ bald_technologist on the IRC channel (irc.freenode.net): #eZpublish ]

<i>When in doubt, clear the cache.</i>

Shurbann Martes

Tuesday 04 November 2003 9:10:05 am

I'm very interested in the hack for content objects you made. If you have some spare time please post this.
Thank you.

Shurbann

Willie Seabrook

Tuesday 04 November 2003 9:20:47 pm

See this post for a huge problem with what I did:

http://www.ez.no/developer/ez_publish_3/forum/developer/huge_performance_problem_1_months_work_down_tubes

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:59:03
Script start
Timing: Jan 19 2025 00:59:04
Module start 'layout'
Timing: Jan 19 2025 00:59:04
Module start 'content'
Timing: Jan 19 2025 00:59:05
Module end 'content'
Timing: Jan 19 2025 00:59:05
Script end

Main resources:

Total runtime1.0204 sec
Peak memory usage4,096.0000 KB
Database Queries62

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 589.1797152.6250
Module start 'layout' 0.00640.0042 741.804739.4453
Module start 'content' 0.01061.0082 781.2500582.0625
Module end 'content' 1.01880.0015 1,363.312512.1563
Script end 1.0203  1,375.4688 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3258160.0002
Check MTime0.00140.1372160.0001
Mysql Total
Database connection0.00120.122310.0012
Mysqli_queries0.965294.5927620.0156
Looping result0.00070.0663600.0000
Template Total0.978395.920.4891
Template load0.00210.209920.0011
Template processing0.976195.661420.4881
Template load and register function0.00020.017210.0002
states
state_id_array0.00200.199610.0020
state_identifier_array0.00130.127620.0007
Override
Cache load0.00170.1701330.0001
Sytem overhead
Fetch class attribute can translate value0.00080.076030.0003
Fetch class attribute name0.00100.101050.0002
XML
Image XML parsing0.00080.074330.0003
class_abstraction
Instantiating content class attribute0.00000.000850.0000
General
dbfile0.00180.1744160.0001
String conversion0.00000.001140.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
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
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/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: 20
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs