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.