The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Feb 28, 2012 2:27 pm 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Feb 19, 2009 9:57 am
Posts: 110
Location: Cambridgeshire / Hertfordshire, Great Britain, Centre of the Universe
Hi all,

I'm creating a custom component in J!2.5.1 and when creating a new menu item link to my component I'd like to add the value from my custom options to the menu item link!

Currently I'm pulling the required data from the params when the view loads. However, this works fine, but I'd also like to add the 'task' paramter to the URL; and if I can do that I'd like to add my other option values as well.

Currently, when creating a menu item link to my component the link field looks like this:

Code:
index.php?option=com_roleprofiler&view=profiler&layout=assessmenthome


I'd like to add the option value from my option dropdown and a task (which would be a static value) as well so this link field looks like this:

Code:
index.php?option=com_roleprofiler&view=profiler&layout=assessmenthome&task=xxx&id=#


The view's XML file looks like this so far:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
   <layout title="COM_ROLEPROFILER_PROFILER_VIEW_SELECTDEPARTMENT_TITLE" option="COM_ROLEPROFILER_PROFILER_VIEW_SELECTDEPARTMENT_OPTION">
      <message>
         <![CDATA[COM_ROLEPROFILER_PROFILER_VIEW_SELECTDEPARTMENT_DESC]]>
      </message>
   </layout>
   <!-- Add fields to the parameters object for the layout. -->
   <fields name="params">

      <!-- Basic options. -->
      <fieldset name="basic" label="Basic Options">
      
         <field name="id" type="sql" label="Assessment" query="SELECT id AS id, title AS title FROM #__roleprofiler_assessments" key_field="id" value_field="title" description="Please select which assessment you are linking this menui  item too." message="Message goes here!" required="true">
            <option value="">Select</option>
         </field>
      
      </fieldset>
   </fields>
</metadata>


Is it a matter of adding further fields to this XML document to force these extra parameters to the link field? If not, could somebody please explain?

Thanks for reading,
Kris...

_________________
Joomla CMS Developer: http://www.kharmer.co.uk


Top
 Profile  
 
PostPosted: Wed Feb 29, 2012 6:04 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Aug 27, 2009 3:07 am
Posts: 103
Location: Troy, MI - USA
take a look at the link, it should give you all the information you are seeking.

http://docs.joomla.org/Developing_a_Mod ... oller_(MVC)_Component_for_Joomla!2.5_-_Part_05

Hope that helps.


Top
 Profile  
 
PostPosted: Thu Mar 01, 2012 10:06 am 
Joomla! Enthusiast
Joomla! Enthusiast

Joined: Thu Feb 19, 2009 9:57 am
Posts: 110
Location: Cambridgeshire / Hertfordshire, Great Britain, Centre of the Universe
Thanks Pocketss, I had skipped over this without noticing.

I now am able to add the ID parameter and value to the link field using this example.

One more thing; how can I add the 'task' parameter and the required value? This would be static for each view that is linked to via Joomla menus. I was thinking parhaps a hidden request field but J! doesnt like this!

This is my file and I've added the hidden field for task as you can see but it only adds '&task=' to the Link field and not the value. What would the value parameter be for the XML (I tried 'value')

Code:
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
   <layout title="COM_ROLEPROFILER_PROFILER_VIEW_ASSESSMENT_TITLE" option="COM_ROLEPROFILER_PROFILER_VIEW_ASSESSMENT_OPTION">
      <message>
         <![CDATA[COM_ROLEPROFILER_PROFILER_VIEW_ASSESSMENT_DESC]]>
      </message>
   </layout>
   <!-- Add fields to the parameters object for the layout. -->
   <fields name="request">
      <fieldset name="request">
         <field name="id" type="sql" label="Assessment" query="SELECT id AS id, title AS title FROM #__roleprofiler_assessments" key_field="id" value_field="title" description="Please select which assessment you are linking this menu item too." message="Message goes here!" required="true">
            <option value="">Select</option>
         </field>
         <field name="task" type="hidden" key_field="assessmenthome" />
      </fieldset>
   </fields>
</metadata>


Any ideas?

_________________
Joomla CMS Developer: http://www.kharmer.co.uk


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group