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
|