Hi,
I'm writing a component which has an advanced search page.
So I created a 'search' view and model, and I figured the view will have two layouts: one for the search form and one for the search results.
Problem is, when I want to add a menu item in the backend, I automatically have the option to add a link to the search results layout, even tough this link is meaningless (linking to search results with no search parameters).
Is there a way to prevent a layout from appearing in the menu->add item page, or maybe my code is not structured correctly?
Thanks!
Prevent menu link for certain layouts
Moderators: tjay, seadap, Rogue4ngel, matthewhayashida
Forum rules
Prevent menu link for certain layouts
Last edited by dodlee on Tue Dec 11, 2007 2:36 pm, edited 1 time in total.
Re: Prevent menu link for certain layouts
Ok, guess I'll answer myself.
So, to prevent a layout from automatically appearing as a menu target option, the xml file for this layout must include the tag:
This XML file is a file with the same name as the layout located with the layout file.
So, assuming the layout will have no options and parameters, the xml file will look like this:
An example from the core files is \components\com_content\views\article\tmpl\pagebreak.xml
Hope this could help somebody
Gooday
So, to prevent a layout from automatically appearing as a menu target option, the xml file for this layout must include the tag:
Code: Select all
<layout hidden="true" />
This XML file is a file with the same name as the layout located with the layout file.
So, assuming the layout will have no options and parameters, the xml file will look like this:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout hidden="true" />
</metadata>
An example from the core files is \components\com_content\views\article\tmpl\pagebreak.xml
Hope this could help somebody
Gooday
Re: Prevent menu link for certain layouts
Thanks for answering yourself.
I was needing this the other day, but I was sidetracked and never finished looking into it.
Thanks again.
I was needing this the other day, but I was sidetracked and never finished looking into it.
Thanks again.
http://springhillalumni.org • Springhill High School Alumni Association
Re: Prevent menu link for certain layouts
Happy to be of service
Re: Prevent menu link for certain layouts
I had a similar problem but fixed it in another way. If you have a view that goes to a list, and another that goes to the details of an item from that list, you may wish the details view to be visible and create the ability to link to a specific item directly, rather than going to the list first.
To do that you need to use elements. Look at the Banners or Contact components for an idea how that works. Generally you set up an elements folder on your admin side and create a php file that does the db lookup and creation of things like a drop down list of items - the name is based on the parameter you then put in an xml file you put in the view/tmpl folder called default.xml.
The code could be like:
"id" is the name of the field you are going to choose from the db lookup, "studiesview" is the file that the site will look for in the elements folder of the admin side. Again, check out one of the core components for how to do this in particular.
These xml files also allow you to restrict what if any parameters show up when an admin creates a menu item for the component. If you put an xml file in the view folder on the site side called metadata.xml, it can have just something like this as code:
Then put a default.xml file into the details view tmpl folder with content that is similar, then when the admin creates a menu item he/she won't have any parameters to choose from.
To do that you need to use elements. Look at the Banners or Contact components for an idea how that works. Generally you set up an elements folder on your admin side and create a php file that does the db lookup and creation of things like a drop down list of items - the name is based on the parameter you then put in an xml file you put in the view/tmpl folder called default.xml.
The code could be like:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: default.xml tf 12-11-2007 $ -->
<metadata>
<layout title="Single Study Layout">
<message>
<![CDATA[Create a link to a single study's details]]>
</message>
</layout>
<state>
<name>Single Study Layout</name>
<description>Choose a single study to link to</description>
<url addpath="/administrator/components/com_biblestudy/elements">
<param name="id" type="studiesview" default="" label="Select a Study" description="The study to link to" />
</url>
</state>
</metadata>
"id" is the name of the field you are going to choose from the db lookup, "studiesview" is the file that the site will look for in the elements folder of the admin side. Again, check out one of the core components for how to do this in particular.
These xml files also allow you to restrict what if any parameters show up when an admin creates a menu item for the component. If you put an xml file in the view folder on the site side called metadata.xml, it can have just something like this as code:
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<!-- $Id: metadata.xml 2007-12-11 $ -->
<metadata>
</metadata>
Then put a default.xml file into the details view tmpl folder with content that is similar, then when the admin creates a menu item he/she won't have any parameters to choose from.
Check out my new component Bible Study:
http://joomlacode.org/gf/project/biblestudy/
http://joomlacode.org/gf/project/biblestudy/