Page 1 of 1

How to set $task in new menu items

Posted: Mon Sep 03, 2007 12:12 am
by uweD
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

Re: How to set $task in new menu items

Posted: Mon Sep 03, 2007 11:50 pm
by doctorD
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

Re: How to set $task in new menu items

Posted: Wed Sep 12, 2007 1:55 am
by uweD
Sorry for reacting so late, and thanks for your help,

I simply missed that postsĀ  :(

Uwe