Menu Parameters - URL or Database?

118 views
Skip to first unread message

Jedimark

unread,
Aug 21, 2012, 4:39:51 AM8/21/12
to joomla-de...@googlegroups.com

Hi,

I am working with Menu Parameters for the first time and I need a little bit of help.

From what I have figured out so far I can define menu parameters which are either appended to the URL or saved in the 'params' field in the database.

So I get either: index.php?option=com_mycomponent&view=default&id=2&theme=green

Or: {"id":"2","theme":"green","menu-anchor_title":"","menu-anchor_css":"","menu_image":"","menu_text":1,"page_title":"","show_page_heading":0,"page_heading":"","pageclass_sfx":"","menu-meta_description":"","menu-meta_keywords":"","robots":"","secure":0}

What I would really like is for the ID parameter to be appended to the URL and for the THEME parameter to be stored in the database. But I'm not sure how to split them like this.

This is my default.xml file:

<?xml version="1.0" encoding="utf-8"?>

<metadata>

 <layout title="SL_COMP_MENU_ITEM_TYPE">

  <message>

   <![CDATA[SL_COMP_MENU_ITEM_TYPE_DESC]]>

  </message>

 </layout>

 <fields name="request">

  <fieldset name="request" addfieldpath="/administrator/components/com_mycomponent/models/fields">

   <field name="id" type="modal_comp" label="SL_CO_SELECT" required="true" />

   <field name="theme" type="list" label="SL_SELECT_THEME" required="true">

    <option value="green">Green</option>

    <option value="blue">Blue</option>

    <option value="red">Red</option>

   </field>

  </fieldset>

 </fields>

</metadata>

My changing <fields name="request"> to <fields name="params"> I get ID and THEME stored in the 'params' but like I said, I'd like ID to be in the URL and THEME to be in the database. Hope I've made sense!!

Many thanks,

Mark

b2z

unread,
Aug 21, 2012, 10:46:49 AM8/21/12
to joomla-de...@googlegroups.com
Hi!

Just create separate fieldset, name it "params" and move there everything except ID.

Best regards,
Dmitry.

Jedimark

unread,
Aug 21, 2012, 11:14:34 AM8/21/12
to joomla-de...@googlegroups.com
Thanks for the reply Dmitry,
 
So simple!
 
Is it possible, however, to have all the options contained within the same page slider. I note creating a separate fieldset also creates a new slider.
 
Thanks,
 
Mark

elin

unread,
Aug 21, 2012, 12:52:29 PM8/21/12
to joomla-de...@googlegroups.com
You really don't want to have things that are part of the request in the request slider. 

You can assign any template style to any menu item so it's best to do it that way  rather than adding the individual parameters to manage the template. Why not make your color list correspond to template styles?

Elin

elin

unread,
Aug 21, 2012, 2:31:19 PM8/21/12
to joomla-de...@googlegroups.com
I mean NOT part of the request. :P  

Ellin

Jedimark

unread,
Aug 23, 2012, 2:09:53 PM8/23/12
to joomla-de...@googlegroups.com
Thank you Ellin.
 
I have another question - this time concerning Component-wide default parameters.
I create this parameter on a new install by adding the following in my components Manifest file:
 
 <config>
  <fields name="params">
          <fieldset name="" description="">
    <field name="test" default="hello" />
          </fieldset>
  </fields>
 </config>
 
This puts {"test":"hello"} into jos_extensions and that's great.
 
However I also want this parameter to be inserted for upgrades to the component. At the moment all I have is {} in the table.
Will I have to run a script on upgrade to check for this or is there a better way?
 
Thanks,
 
Mark

Rouven Weßling

unread,
Aug 23, 2012, 2:47:56 PM8/23/12
to joomla-de...@googlegroups.com

On 23.08.2012, at 20:09, Jedimark <jedi...@gmail.com> wrote:

Will I have to run a script on upgrade to check for this or is there a better way?

The way we employ in the core is that we supply the default value when get the param (second argument of the get method). This way we a also have a failsafe when something goes wrong in the database.

Rouven

Jedimark

unread,
Aug 23, 2012, 2:55:12 PM8/23/12
to joomla-de...@googlegroups.com
Thanks Rouven - I wasn't aware of the second argument of get.
 
Mark
Reply all
Reply to author
Forward
0 new messages