how do i get the $params->get to work from within a function ?

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
iNFiLTaToR
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Nov 16, 2007 10:09 am

how do i get the $params->get to work from within a function ?

Post by iNFiLTaToR » Fri Nov 16, 2007 10:22 am

Hi ,

Joomla 1.0.13 problem...

I'm trying to write a module that has several parts...
I splitted up the functions of my module into functions, but the data that i retrieve through the function is not sowing up...

I go to my page and it standard shows content , when submitting to that same page its showing other content depending on what is submitted
I have several submits , so i putted al the possebilitys into several functions

that function then gets the data from the params in the module.xml file and then my table / page and so on is build in the same script and put into 1 variable , and that variable is set into a template that is then shown by the html output.

All of that works fine except of the data that i try to retrieve with the get--> $param
all i get is the default value...

Joomla help quote
The mosParameters class constructor takes two arguments, the first the textual parameter values retrieved from the database, and the second in the xml setup file where the parameters are defined. See the following example:

global $mainframe;

$option = 'com_content';

// get params definitions
$params =& new mosParameters( $menu->params,  $mainframe->getPath( 'com_xml', $option ), 'component' );

To display the parameters pass the params variable to your display function and simply echo the text returned by the "render" method, for example:

render();
}
?>
mod_whois.php

Code: Select all

function ToonPakketPrijzen($joomlaref, $debug)
	{
                                
		global $mainframe;
		
          $params = & new mosParameters( $module->params , $mainframe->getPath( 'com_xml', 'mod_whois' ), 'module' );
		
		$pakketn1 = $params->get( 'naam1', 'Pakket 1' );
		$pakketn2 = $params->get( 'naam2', 'Pakket 2' );
		$pakketn3 = $params->get( 'naam3', 'Pakket 3' );
		
		$webruimte1 = $params->get( 'webr1', '5 MB' );
		$webruimte2 = $params->get( 'webr2', '6 MB' );
		$webruimte3 = $params->get( 'webr3', '7 MB' );
                }
mod_whois.xml

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<mosinstall type="module" version="4.5.2">
  <name>Whois</name>
  <author>Eeckhaut Didier</author>
  <creationDate>oktober 2007</creationDate>
  <copyright>(C) 2007 Smart Trade bvba</copyright>
  <version>1.0</version>
  <description>Modulle Whois</description>
  <files>
    <filename module="mod_whois">mod_whois.php</filename>
    <filename>mod_whois/mod_whois.html</filename>
  </files>
	<params name="whois">
		<param name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" 
			description="Een voorvoegsel dat moet toegevoegd worden aan de css class van de module(table.moduletable),
										dit laat toe om de module individueel te stylen" />
		
		<param name="@spacer" type="spacer" default="" label="*** Pakket 1 ***" description="" />
		
		<param name="naam1" type="text" size="12" default="" label="Naam"
			description="Te displayen naam voor het pakket" />
		<param name="webr1" type="text" size="9" default="" label="Webruimte"
			description="Hoeveelheid webruimte ( eenheid ook op te geven )" />
		<param name="datal1" type="text" size="9" default="" label="Data Limiet"
			description="Hoeveelheid Toegestane Datalimiet ( eenheid ook op te geven )" />
                          </params>
</mosinstall>
I dont get the params to work in a function...

So how do i get the $params->get to work from within a function ?
Last edited by iNFiLTaToR on Fri Nov 16, 2007 12:30 pm, edited 1 time in total.

iNFiLTaToR
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Nov 16, 2007 10:09 am

Re: how do i get the $params->get to work from within a function ?

Post by iNFiLTaToR » Fri Nov 16, 2007 2:06 pm

Found the solution to the problem..

putting following code to the main body of the .php file

Code: Select all

$params = & new mosParameters( $module->params);
passing it on to the functions that need it...

Code: Select all

ToonWhois($joomlaref,$debug, &$params);
Call the parameters from within the function

Code: Select all

$respond1 = $params->get( 'respond1', 'Geen' );

Opie
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Thu Jun 22, 2006 7:32 pm
Contact:

Re: how do i get the $params->get to work from within a function ?

Post by Opie » Mon Nov 19, 2007 5:11 pm

Thanks for posting your solution.
http://springhillalumni.org • Springhill High School Alumni Association


Post Reply