Help needed: Passing parameters from URL to PHP module

Author Message

Massimiliano Bariola

Friday 10 June 2005 2:35:39 am

Hi,

I'm currently trying to develop an extension module that will read data from an external database table according to certain URL parameters. To do so, I first tried my hand at customizing the eurofxref extension I found on a post on the forums.
If called with no parameters, the extension would display the whole list of currencies, while if called with a currency symbol (say DKK) it would have to show only the entry relevant to the selected currency.

I have trouble with getting the URL parameters accepted. So far, I was able to:

1) Pass the URL ordered parameter to the tpl file
2) Pass the URL ordered parameter to the php file using the $Params[array]

What I want to achieve, is to get the URL ordered parameter to be passed as an argument to the function fetchFX of the EuroFxRef class, so that I can restrict my data fetching at the php level.

this is the relevant part from my eurofxref/function_definition.php :

$FunctionList = array();

$FunctionList['fxref'] = array(
'name' => 'fxref',
'operation_types' => array( 'read' ),
'call_method' => array(
'include_file' => 'extension/eurofxref/modules/eurofxref/classes/eurofxref.php',
'class' => 'EuroFxRef',
'method' => 'fetchFX'),
'parameter_type' => 'standard',
'parameters' => array(
array(
'name' => 'CurrencySymbol',
'type' => 'string',
'required' => false))

this is the eurofxref/module.php ...

$Module = array( 'name' => 'Eurofxref' );

$ViewList = array();
$ViewList['overview'] = array(
'script' => 'overview.php',
'functions' => array( 'read' ),
'params' => array('CurrencySymbol')
);

$FunctionList['read'] = array();

this is the overview.tpl part .... (I tried various ways to pass the parameter through the fetch, all of them giving me an error :) )

{def $rates=fetch( 'eurofxref', 'fxref', array($currSymbol))}
{if ne( $currSymbol, '') }
<h1>Currency Symbol = {$currSymbol}</h1>
.......

here is the overview.php file ...

include_once( 'kernel/common/template.php' );

$tpl = & templateInit();
$tpl->setVariable( 'currSymbol', $Params['CurrencySymbol'] );

$Result = array();
$Result['content'] = &$tpl->fetch( 'design:eurofxref/overview.tpl' );
$Result['path'] = array( array( 'url' => '/eurofxref/overview',
'text' => 'Tassi di conversione con l\'Euro!' ) );

this is the class definition and how I thought the param to be passed in eurofxref/classes/euroxref.php

class EuroFxRef {

// static
function fetchFX($CurrencySymbol) {

.....

I am quite sure that the params _can_ be passed to the function, and the key to that must be in the function_definition.php. Yet, I can't get it to work after 2 days of head-banging.

Any nudge in the right direction?

thanks,

MB

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 20 2025 09:58:20
Script start
Timing: Jan 20 2025 09:58:20
Module start 'layout'
Timing: Jan 20 2025 09:58:20
Module start 'content'
Timing: Jan 20 2025 09:58:21
Module end 'content'
Timing: Jan 20 2025 09:58:21
Script end

Main resources:

Total runtime1.4793 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0067 589.3906152.6406
Module start 'layout' 0.00670.0034 742.031339.4766
Module start 'content' 0.01021.4677 781.5078457.8203
Module end 'content' 1.47790.0014 1,239.328112.1250
Script end 1.4793  1,251.4531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.2550160.0002
Check MTime0.00150.0997160.0001
Mysql Total
Database connection0.00150.098410.0015
Mysqli_queries1.414895.6398460.0308
Looping result0.00050.0357440.0000
Template Total1.442997.520.7214
Template load0.00240.159520.0012
Template processing1.440597.373820.7202
Template load and register function0.00020.014510.0002
states
state_id_array0.00180.119910.0018
state_identifier_array0.00300.204520.0015
Override
Cache load0.00200.1319570.0000
Sytem overhead
Fetch class attribute can translate value0.00100.067310.0010
Fetch class attribute name0.00080.056420.0004
XML
Image XML parsing0.00200.135510.0020
class_abstraction
Instantiating content class attribute0.00000.000320.0000
General
dbfile0.00310.2075170.0002
String conversion0.00000.000340.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
9content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs