Joomla component not appearing in the menu item types - joomla

I just followed the joomla tutorials on how to create the "perfect" MVC joomla component. However, my problem is that I don't know yet how to assign it to a menu. I thought that my component would then just show up when I select a "menu item type", but my component is not on this list. I've made some research on Google, but I cannot find the answer... Do I have to create a metadata.xml file or something similar ?
Thanks in advance for your answers !!

To create "views" for your component, you have to create some xml files.
Inside the templates folder in the frontend part of your component (usually something like /components/com_yourcomponent/views/someview/tmpl), if you had a template named default.php and form.php, you can create a default.xml file and a form.xml file to make these menu items available from the administrator.
You can take a look at other components to see the structure of these xml files, but what you should put inside is:
1) A name and a description for four view
2) The params the user will be able to change from the administrator (it works like module/plugin params)
3) You can also set "hidden" request variables for that menu item. It means that those vars will be added to the request in that particular menu item, but the user won't be able to change its value.
Here's a complete example for a component (Joomla 1.7):
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_AGMTAGS_TAG_VIEW_DEFAULT_TITLE">
<message>COM_AGMTAGS_TAG_VIEW_DEFAULT_DESC</message>
</layout>
<fields name="request" addfieldpath="/administrator/components/com_agmtags/models/fields">
<fieldset name="request">
<field name="tag_id" type="agmtag"
label="COM_AGMTAGS_TAG_FIELD_NAME_LABEL"
description="COM_AGMTAGS_TAG_FIELD_NAME_DESC"
/>
</fieldset>
</fields>
<fields name="params">
<fieldset name="basic" label="COM_AGMTAGS_TAG_OPTIONS">
<field name="layout_type" type="hidden" default="blog" />
<field name="show_tag_name" type="list"
label="COM_AGMTAGS_SHOW_TAG_NAME"
description="COM_AGMTAGS_SHOW_TAG_NAME_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="show_tag_description" type="list"
description="COM_AGMTAGS_SHOW_TAG_DESCRIPTION_DESC"
label="COM_AGMTAGS_SHOW_TAG_DESCRIPTION_LABEL"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="items_per_page" type="text" default="" />
<field name="container_class" type="text" default="agmtags-list" />
</fieldset>
</fields>
</metadata>
I hope it helped!

If you simply want to add the view link to the list create a xml file called default.xml inside the com_yourcomponent/views/yourviewname/tmpl/
The xml code below takes two language strings used to display your menu item link in the list
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="COM_YOURCOMPONENT_FRONPAGE_TITLE">
<message>COM_YOURCOMPONENT_FRONPAGE_MSG</message>
</layout>
</metadata>
save the file and the link should appear in the list of menu items

Apparently, you also need the administration menu tags in your installation XML file.
http://forum.joomla.org/viewtopic.php?p=706714
This worked for me
<administration>
<menu>COM_COMPONET</menu>
<submenu>
etc...
</submenu>
Think this is what Panayiotis was trying to say

Additionally there is also another catch.
In the installation XML file of the component,
in the section, the tags must
be present, even if you do not need the menu.
If these are missing, then you'll never be given
the option to add this component to a menu item,
because the type wont be there :-)

In additional, your alternative view file names MUST NOT be written with underscores.
table_catalog.xml
table_catalog.php
table_catalog_item.php
didn't work - there wasn't new option in "menu item type" list. But
tablecatalog.xml
tablecatalog.php
tablecatalog_item.php
file names work perfectly. I've lost an hour revealing a problem.

Related

custom button in Joomla module admin panel

New to Joomla(one month).
I'm trying to create a module that will list events(names and times). I want the module to be populated from the admin panel. For example lets say the module lists would list the following on the front end:
breakfast ........ 9:30
lunch .............12:30
dinner ............7:30
In the admin panel there will be input text fields for the admin to add/delete the events and a button(s) that will call a js function execute add/delete.
I am using Joomla4 I'm under the impression that all I need to do is tell the manifest file about my button in the configs sections and then write the javascript in the mod_project.php file that will add/delete a field on press. (Perhaps the js needs to go in the tmpl/default.php I'm not entirely sure where to put it) Unfortunately my attempt to add a button in the config file has failed meaning there is no output in the html:
current config section of manifest file:
<fields name="params">
<fieldset name="basic">
<field
name="event_name_0"
type="text"
label="Event Name"
filter="event"
/>
<field
name="event_time_0"
type="text"
label="Event Time"
filter="event"
/>
<button type="submit" id="testBtn" value="Add">Add</button>
</fieldset>
</fields>
</config>
I have to do that yesterday but I have found a solution more simple : I just added a custom field, for my specific category, with the type repeatable and I have written a module to read this specific field.

Adding menu types with custom url parameters to component in Joomla 3

I'm having problems adding custom url parameters to my component menu. My component displays different data on the same view depending on which value from predetermined set is passed via custom GET parameter. For example, let's say these two urls are the only valid variants of the same view:
?option=com_mycomponent&view=myview&option=hello
?option=com_mycomponent&view=myview&option=world
How can I add these two urls as separate menu types to the component?
you need to change your default.xml file in such a way that when you create menu it will ask you for the optional parameter.
The default.xml file located at component/your_component/views/yourview/tmpl/default.xml
The code will look like as below
<fields name="request">
<fieldset name="request">
<field name="option" type="hidden"
label=""
required=""
description=""
default="default-value"
/>
</fieldset>
</fields>
For reference check components/com_content/views/article/tmpl/default.xml file
You can use External URL.
Create a new menu and select External URL from Menu Item Type > System Links. Add your urls in the Link field.
I hope I was of any help.

How to set parameters in menu Item Joomla Component

Following is my code.
<fields name="request">
<fieldset name="request">
<field name="format" type="list" label="COM_CPS_FIELD_FORMAT"
description="COM_CPS_FIELD_FORMAT_DESC" class="small"
default="raw"
>
<option value="">COM_CPS_FORMAT_HTML</option>
<option value="raw">COM_CPS_FORMAT_RAW</option>
</field>
</fieldset>
</fields>
When I save the menu with 2nd option it save the url like this index.php?option=com_cps&view=webservice&format=raw but when I save the menu with first option it does not remove the &format=raw If any one can help me out It would be great.
Default is defined as what to save if nothing is posted. It works like a Joomla input filter in that it changes what is actually saved as opposed to validation which stops the process and never posts. Therefore you cannot save nothing, since it will always be replaced by the default. Therefore if you want to be able to save blank you must not have a default.
What you may be looking for is a preset, which is a preselected value that can be unselected. Presets and defaults are totally different things although on the surface they appear similar.

Adding category parameter(s)

I'm developing extension, using native Joomla categories. I would like to add one additional parameter in category editor, which only be used when editing my extension's category.
The question:
Is it possible without overriding Joomla core files?
The previous answer (new XML file) is very close, but doesn't quite work in Joomla 3.x. To make it work I had to change the name attribute of the fields element to "params" as follows:
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset name="basic" label="Group settings">
<field name="group_id" type="list" default="" label="Select group:">
<option value=""></option>
<option value="1">Group 1</option>
<option value="2">Group 2</option>
<option value="3">Group 3</option>
</field>
</fieldset>
</fields>
</form>
This way, the custom options show in the options tab of the category edit screen.
Also, if you have more than one type of category in your component (for example, "com_mycomponent.mycategorytype"), you need to make the name of the XML file "category.mytype.xml".
Well actually after night of no sleep i was able to find an elegant native solution.
Unfortunately Joomla devs didn't documented it, but it appears that in your extension you create file:
/administrator/components/com_YourName/models/forms/category.xml and add there a fieldset "attribs" it automatically appears in your extension's category manager.
Sample code of category.xml here:
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="attribs">
<fieldset name="attribs" label="Group settings">
<field name="group_id" type="list" default="" label="Select group:">
<option value=""></option>
<option value="1">Group 1</option>
<option value="2">Group 2</option>
<option value="3">Group 3</option>
</field>
</fieldset>
</fields>
</form>
UPDATED
Yes, this can also be done without hacking core files.
You can create a template override for the administrator com_categories component.
Copy this file:
administrator/components/com_categories/views/category/tmpl/edit.php
in this path (you need to create the corresponding directories):
administrator/templates/bluestork/html/com_categories/category/edit.php
In this new file you can work all your magic.
If you need something more advanced, you can use a plugin that allows you to override models and any other part of the component: Plugin Override

Whats the easiest way to add custom style to the module parameters form at the admin in Joomla?

My simple module using 3 field, 2 text input and a tinymce textarea, but the textarea looks broken. http://img151.imageshack.us/img151/8648/joomla464.jpg
This is my config:
<config>
<fields name="params">
<fieldset name="basic">
<field name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" description="PARAMMODULECLASSSUFFIX" />
<field name="url" type="text" default="" label="Paste the url" description="" />
<field style="clear:both;float:left;background-color:red;" name="description" type="editor" default="default" rows="20" cols="40" />
</fieldset>
</fields>
</config>
ty
You could add your css to
administrator/templates/bluestork/css/template.css (That is if your using the default administration template)
but there is a risk when joomla updates you will lose your css... you could alwasy copiy the template... give it a diffrent name and update the css there. so your copie wont be affected by any joomla update.
so adding your css there you just need to use the right css selector.
Otherwise i would use an artical selector or category selector
<field
name="category_id"
type="category"
description="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_DESC"
extension="com_content"
label="JGLOBAL_FIELD_CATEGORIES_CHOOSE_CATEGORY_LABEL"
show_root="true"
required="true" />
And put what ever content you need in an artical.. you dont have much room to put the editor on the right for the modules configurations anyway.

Resources