Reputation: 733
I am creating a component (no MVC) for my joomla site and I would like to have 2 php pages that I can display.
So I have myprog.php and myprog2.php in the site folder. In order to be able to select the myprog.php to assign it to a menu, I have created a default.xml file in the folder /site/views/myprog/tmpl/
And it contains:
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_MYPROG_DEFAULT_TITLE">
<message>
<![CDATA[COM_MYPROG_DEFAULT_DESC]]>
</message>
</layout>
</metadata>
How can I have this for my second page so that I can select the second page to assign it to a menu?
Thanks.
Upvotes: 0
Views: 150
Reputation: 28775
You need to create one more file same as default.xml at the same location. Its name will be layout name as well. For example its name is blog.xml. When you create menu of this, then it will automatically add layout=blog
in url.
As you are not using MVC then you can check for layout variable in get values and can work accordingly.
And if you use MVC pattern, then you just need to set layout in view and create tmpl files which must start with layout name. for example : tmpl file in default and blog layout will be like
default.php => blog.php
default_edit.php => blog_edit.php
Upvotes: 0
Reputation: 87
I would use MVC :-) If you insist, Here there is an article on how to add a parameter in the menu instance creation: http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!2.5_-_Part_06#site.2Fviews.2Fhelloworld.2Ftmpl.2Fdefault.xml
It contains:
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_TITLE">
<message>COM_HELLOWORLD_HELLOWORLD_VIEW_DEFAULT_DESC</message>
</layout>
<fields
name="request"
addfieldpath="/administrator/components/com_helloworld/models/fields"
>
<fieldset name="request">
<field
name="id"
type="helloworld"
label="COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_LABEL"
description="COM_HELLOWORLD_HELLOWORLD_FIELD_GREETING_DESC"
/>
</fieldset>
</fields>
</metadata>
I assume that you can change the field to a radio box. You may see joomla available field types in: http://docs.joomla.org/Standard_form_field_types (you don't need to create your onw field type - use radio)
I would use the radio option: http://docs.joomla.org/Radio_form_field_type
I suppose (without testing it) I would go like that:
<field name="pagetoshow" type="radio" default="0" label="Select an option" description="">
<option value="0">Page this</option>
<option value="1">Page that</option>
</field>
In the end you can use
$jinput = JFactory::getApplication()->input;
$pagetoshow = $jinput->get('pagetoshow', 1, 'INT' );
in your view.html.php and with an if statement show the appropriate page.
Upvotes: 1