How to set $task in new menu items

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
User avatar
uweD
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Mon May 14, 2007 9:38 pm
Location: Auckland -- New Zealand
Contact:

How to set $task in new menu items

Post by uweD » Mon Sep 03, 2007 12:12 am

OK,
and another question more or less in the same direction:

I try to add a link to he main menu using the add menu item dialog. This link supposed to point to the create view of of my component xyz. The problem that I have that this link does say anything about the task my component is supposed to get onto.

example:
The link that looks like that:
index.php?option=com_xyz&view=xyzCreateLandingPage&layout=createLandingpage
what I expexted to see is
inex.php?option=com_xyz&view=xyzCreateLandingPage&layout=createLandingpage&task=createobject

Anyone any idea?

Thanks,
Uwe
Last edited by uweD on Wed Sep 12, 2007 1:55 am, edited 1 time in total.
________________________
Uwe Duesing
http://www.uweduesing.com
Skype:uweOnehunga

doctorD
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Sat Sep 01, 2007 8:31 pm

Re: How to set $task in new menu items

Post by doctorD » Mon Sep 03, 2007 11:50 pm

uweD wrote: OK,
and another question more or less in the same direction:

I try to add a link to he main menu using the add menu item dialog. This link supposed to point to the create view of of my component xyz. The problem that I have that this link does say anything about the task my component is supposed to get onto.

example:
The link that looks like that:
index.php?option=com_xyz&view=xyzCreateLandingPage&layout=createLandingpage
what I expexted to see is
inex.php?option=com_xyz&view=xyzCreateLandingPage&layout=createLandingpage&task=createobject

Anyone any idea?

Thanks,
Uwe
In your XML file for your component, create a parameters section and include tabs for your parameters. You can then access this using J Menu get instance.

Sample XML file

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<install type="component" version="1.5.0">
	<name>Title</name>
	<author>auhtor</author>
	<creationDate>date</creationDate>
	<copyright>copyright</copyright>
	<license>link to license</license>
	<authorEmail>email</authorEmail>
	<authorUrl>website</authorUrl>
	<version>version</version>
	<description>description</description>
	<params>
		<param name="task" type="text" default="0" label="Task link" description="task to perform">
		</param>
	</params>
</install>

Sample code to get parameter:

Code: Select all

	$menu =& JMenu::getInstance();
	$item = $menu->getActive();
	$params =& $menu->getParams($item->id);
	$linksection = $params->get('task',1);
Hope that helps

User avatar
uweD
Joomla! Apprentice
Joomla! Apprentice
Posts: 39
Joined: Mon May 14, 2007 9:38 pm
Location: Auckland -- New Zealand
Contact:

Re: How to set $task in new menu items

Post by uweD » Wed Sep 12, 2007 1:55 am

Sorry for reacting so late, and thanks for your help,

I simply missed that posts  :(

Uwe
________________________
Uwe Duesing
http://www.uweduesing.com
Skype:uweOnehunga


Post Reply