Page 1 of 1

Dynamic Values in <Params> in component.xml [J1.0]

Posted: Fri Mar 07, 2008 9:43 pm
by ichneumon
Is there any way to dynamically set the values in the Parameters section of a menu item? Specifically, I'd like to populate a select field with options pulled through from a db.
For example, I have the following in my component.xml

Code: Select all

    <params>
       <param name="category" type="list" default = "0" label="Display Category" description="Test">
         <option value="0">First</option>
         <option value="1">Second</option>
         <option value="2">Third</option>
      </param>
I need to replace these with values selected from one of the component's dbs, so that it becomes something like:

Code: Select all

<option value="<?php echo $id; ?>"><?php echo $name; ?></option>
for each value found. Is there any way to tell Joomla to update the relevant xml values while parsing?
My current workaround is to use a url link with the $id value added by hand, but this is not very flexible, or convenient for the content managers. Fortunately, it's not a value that will change very often, but I'd prefer a more elegant approach.

Re: Dynamic Values in <Params> in component.xml [J1.0]

Posted: Sat Mar 08, 2008 2:11 am
by Bodom78
You could create the options in your view like this based on the database call to pull the required items.

Re: Dynamic Values in <Params> in component.xml [J1.0]

Posted: Sat Mar 08, 2008 8:16 am
by ichneumon
Thanks Bodom78 - however, I have no problem creating the dropdown (I'm an experienced php/mySQL coder, just new to Joomla). The question is aimed at whether I can get these values into the parameters section of a Component menu item. Also, from my reading so far, Joomla 1.0x doesn't have the MVC framework implemented. I'm updating an existing site, and upgrading isn't currently feasible.

Re: Dynamic Values in <Params> in component.xml [J1.0]

Posted: Sat Mar 08, 2008 5:26 pm
by Bodom78
I believe if your setting you params in the component .xml then their generally preset unless its a core list like Joomla's categories.

You can create custom radio options, or drop downs from within your component by using the mosHTML class for Joomla 1.0.x. You can find a list of it's functions and examples here.

Just fill the arrays to generate the radio or drop down lists with queries from your database.

Hope that helps.