Module parameters

Author Message

Julien Plesniak

Monday 30 July 2007 2:16:08 am

Hello, i try to build a new module but i have a problem. I write this code:

<form method="post" action={"content/action/"|ezurl}>
            <input type="hidden" name="ContentNodeID" value="{$node.node_id}" />
	    <input type="hidden" name="test" value="42" />
	    <input type="submit" name="modulego" value="Test Julien" />   
        </form>

I have declared my parameters in module.php:

$ViewList["modulego"] = array(
    "functions" => array( 'use' ),
    "script" => "modulego.php",
    'ui_context' => 'administration',
    "default_navigation_part" => 'ezcontentnavigationpart',
    "params" => array( 'ContentNodeID', 'test'));

But when i do this:

$nodeID =& $Params['ContentNodeID'];
$test =& $Params['test'];


or $test =$Params['test'];

I get the nodeID but i didn't get the "test" parameter, it is empty.

Why i dont get the value of this parameter?

Thanks for help

Heath

Monday 30 July 2007 12:10:01 pm

Why not use the eZ http variable naming convention for your form variables?
<i>http://ez.no/ezpublish/documentation/development/standards/php#eztoc80797_13</i>

I think this is MixedCaseStyle convention. I would try to change 'test' to 'TestVariable' and try again.

Also if that does not meet your needs you may wish to change 'params' to 'unordered_params' and try again.

Cheers,
Heath

Brookins Consulting | http://brookinsconsulting.com/
Certified | http://auth.ez.no/certification/verify/380350
Solutions | http://projects.ez.no/users/community/brookins_consulting
eZpedia community documentation project | http://ezpedia.org

Bruce Morrison

Monday 30 July 2007 4:34:13 pm

Hi Julien

The "params" in the module.php definition refers to parameters that are passed in the URL not via a form.

Your definition allows for URLs of the form /modulename/modulego/[ContentNodeID]/[test] This will set the $Params values you require but I'm not sure that this is the easiest way to achieve what you are trying to do.

You are probably better off retrieving the form variables using the eZHTTPTool. class e.g.

include_once( "lib/ezutils/classes/ezhttptool.php" );
$http =& eZHTTPTool::instance();
$test=false;
$ContentNodeID=false;
if ( $http->hasPostVariable( 'ContentNodeID' ) )
  $ContentNodeID=$http->postVariable( 'ContentNodeID' );
if ( $http->hasPostVariable( 'test' ) )
  $test=$http->postVariable( 'test' );

See http://pubsvn.ez.no/doxygen/trunk/html/classeZHTTPTool.html

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Julien Plesniak

Tuesday 31 July 2007 12:51:24 am

Thanks it work perfectly

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 31 2025 07:37:50
Script start
Timing: Jan 31 2025 07:37:50
Module start 'layout'
Timing: Jan 31 2025 07:37:50
Module start 'content'
Timing: Jan 31 2025 07:37:50
Module end 'content'
Timing: Jan 31 2025 07:37:50
Script end

Main resources:

Total runtime0.0138 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0051 588.0156151.1953
Module start 'layout' 0.00510.0022 739.210936.6328
Module start 'content' 0.00740.0049 775.843894.2500
Module end 'content' 0.01230.0015 870.093833.9922
Script end 0.0138  904.0859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002215.9870140.0002
Check MTime0.00107.2270140.0001
Mysql Total
Database connection0.00074.961110.0007
Mysqli_queries0.002618.775330.0009
Looping result0.00000.079310.0000
Template Total0.00117.810.0011
Template load0.00086.009610.0008
Template processing0.00021.734810.0002
Override
Cache load0.00064.078210.0006
General
dbfile0.00128.359980.0001
String conversion0.00000.043140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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