Extra parameters - $view_parameters doesn't work?!

Author Message

rhodri davies

Wednesday 22 October 2003 8:59:31 am

Hi,

The last section on this page (http://www.ez.no/developer/ez_publish_3/documentation/customization/custom_design/file_placement) suggests that it is possible to pass extra parameters to pages as key/value pairs - however I am unable to get these extra parameters to work as the document suggests.

For example:

http://www.mysite.com/index.php/content/view/full/51/myval1/10/myval2/20

Will not render {$view_parameters.myval1} or {$view_parameters.myval2} with any values.

It seems as tho the line handling this in content/view.php

175: $viewParameters = array( 'offset' => $Offset );

only stores the offset parameter that is picked up in content/module.php

$ViewList["view"] = array(
"functions" => array( 'read' ),
"default_navigation_part" => 'ezcontentnavigationpart',
"script" => "view.php",
"params" => array( "ViewMode", "NodeID" ),
"unordered_params" => array( "language" => "Language",
"offset" => "Offset" )
);

I did try changing the line in view.php to

175: $viewParameters = $Params[ 'Parameters' ]; //array( 'offset' => $Offset );

But that gives a integer indexed array and not a string indexed array which would be more useful in this situation.

Is there a function in eZp to transpose this array from the sequential key/value pairs into a string indexed array which uses the key as the index value?

Regards

Rhodri Davies

rhodri davies

Wednesday 22 October 2003 9:37:26 am

I have written a quick patch for this:

Replace this line in view.php

$viewParameters = array( 'offset' => $Offset );

with this

$viewParameters = $Params[ 'Parameters' ];
$viewParameters = array_slice( $viewParameters, 2 );
$viewParameters = array_slice( $viewParameters, 0, count( $viewParameters ) - 1 );

$tempViewParameters = Array();

for ( $pcount=0; $pcount < count( $viewParameters ) - 1; $pcount = $pcount + 2) {

$tempViewParameters[ $viewParameters[ $pcount ] ] = $viewParameters[ $pcount + 1 ];

}
$viewParameters = $tempViewParameters;

It's may look a bit messy but that's because I've only started using php recently. Now I can send all the extra variables I want and they are all accessable via $viewParameters in the template. :-)

I would really like to know if this should already be in eZp or I've missed something.

Regards

Rhodri Davies

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.