Forums / Developer / Help needed: Passing parameters from URL to PHP module

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

eZ debug

Timing: Jan 15 2025 07:43:37
Script start
Timing: Jan 15 2025 07:43:37
Module start 'content'
Timing: Jan 15 2025 07:43:38
Module end 'content'
Timing: Jan 15 2025 07:43:39
Script end

Main resources:

Total runtime1.3318 sec
Peak memory usage6,144.0000 KB
Database Queries176

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0071 684.4844214.7734
Module start 'content' 0.00711.1728 899.25781,730.2422
Module end 'content' 1.17990.1519 2,629.5000631.4844
Script end 1.3318  3,260.9844 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00650.4899210.0003
Check MTime0.00150.1092210.0001
Mysql Total
Database connection0.00070.053910.0007
Mysqli_queries1.241593.21831760.0071
Looping result0.00180.13551730.0000
Template Total1.298797.520.6494
Template load0.00330.246520.0016
Template processing1.295497.266220.6477
Template load and register function0.00120.091310.0012
states
state_id_array0.00080.063410.0008
state_identifier_array0.00100.074620.0005
Override
Cache load0.00310.2301570.0001
Sytem overhead
Fetch class attribute can translate value0.00170.126120.0008
Fetch class attribute name0.00180.137620.0009
XML
Image XML parsing0.00080.063420.0004
class_abstraction
Instantiating content class attribute0.00000.000220.0000
General
dbfile0.00090.0659220.0000
String conversion0.00000.000530.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

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
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs