Forums / Developer / HTTP POST & GET Hack (instead of ezenv)

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

eZ debug

Timing: Jan 31 2025 06:28:23
Script start
Timing: Jan 31 2025 06:28:23
Module start 'content'
Timing: Jan 31 2025 06:28:23
Module end 'content'
Timing: Jan 31 2025 06:28:23
Script end

Main resources:

Total runtime0.0164 sec
Peak memory usage2,048.0000 KB
Database Queries4

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0061 587.9531180.8281
Module start 'content' 0.00610.0069 768.781397.8828
Module end 'content' 0.01300.0033 866.664174.7031
Script end 0.0163  941.3672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002012.2593120.0002
Check MTime0.00095.6274120.0001
Mysql Total
Database connection0.00105.971010.0010
Mysqli_queries0.002514.981340.0006
Looping result0.00000.104820.0000
Template Total0.003018.310.0030
Template load0.00074.046610.0007
Template processing0.002314.206910.0023
Override
Cache load0.00042.698710.0004
General
dbfile0.002012.2957100.0002
String conversion0.00000.049530.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs