how to use the template for a custom component - php

I've created a custom coponent for joomla and I've created a menu which uses that component and set a template for that menu. The thing is when I go to the url
test.com/index.php?option=com_mycomponent, it still uses the default template instead of the template that I set it to.
in short: The component works, only it's using the wrong template.

You are missing the Itemid for the menu item in your URL. The Itemid is what Joomla uses to look up the menu item, which is what your secondary template is assigned to. Without the Itemid, Joomla uses the system defaults.
If you have the search engine friendly links turned on, Joomla will look up the corresponding menu item in the database for you. In that case, you would not have to specify the Itemid, but you would have to use the menu item's URL as the base instead of index.php?option=com_mycomponent.

FP is right-on about the Itemid. In addition, you can also append a &template=[templatename] to the URL to force any component in Joomla to use the specified template.
matt

Related

How can you create a View in Drupal using a Rule's action?

I would like to create a module that generates a view with predefined settings when a term is created in a particular taxonomy.
I understand that a module can create a view using hook_views_default_views(), but this doesn't allow you to create a view 'on-action', as would be desirable using Rules.
As far as I can see there is no default Rule action that allows creating of views, so is it possible to programmatically create a rule with an action that can create a view?
You may use the Taxonomy Menu Module. It automatically creates menu items based on a vocabulary and integrates nicely with Views as well as Pathauto (for nice urls).
There are two Youtube Videos (here & here) which might help you get along the way.
The Taxonomy Menu Module will create the menu items (linking by default to taxonomy/term/[tid]). The default Taxonomy Term View already listens to these requests and with Pathauto you can create custom aliases (e.g. category/[term_name] for these links which will in turn be used for the rendering of menu items and still work with Views as internally the default urls are used.

Template specific parameters for menu item in joomla

I have a menu in joomla that appears on all pages. Some of the items in the menu should be the same on every page, while others need to be dynamically updated based on the page the user is on. I am trying to create an override for the "external url" menu item type (listed under system links), that would allow me to create a menu item parameter the user could populate. Then, I could use this parameter in the menu template to determine what needs to be added to that particular link.
I understand Joomla overrides for the most part, but I can not figure out where the xml file for these system link menu items is located. If my understanding is correct, overrides should be stored in templates > myTemplate > html > com_myComponent or mod_myModule. I would assume if I knew what component the system links fall under, I could create an override for the xml file. Is this correct or way off?
TL;DR: Where is the xml file for menu item type "external url"?
It seems there is no specific xml-files for the system links, as they are defined directly in
administrator/components/com_menus/views/menutypes/view.html.php
which means there is no xml-file to override. You can, however, override the view class MenusViewMenutypes, which is defined in the view.html.php-file. This is done by writing a system plugin loading a file containing the same class. The recipe is simply and beautifully described here.

more than one text separator style per template in joomla 3.0

Let me first explain what I am trying to do.
In joomla 3.0 I have created a Menu_Item_Text_Separator override for my template http://docs.joomla.org/Help30:Menus_Menu_Item_Text_Separator. It seems as though joomla will only recognize one default Text separator per template which is ok if you just want the one. but I ideally would like to have the choice of selecting the custom one in my template folder as well as the default one that joomla recognizes. To inform you this is what I have done to make it happen.
in my template I have a folder named html which had a folder called mod_menu inside it.
In the mod_menu folder I have the .php files called:
default_separator.php
custom_separator.php
I then go into menu manager and edit the menu item for which I want to display a text separator for.
I then go to 'template style' http://docs.joomla.org/Help30:Menus_Menu_Item_Text_Separator and look for my custom style. but I only can choose the default one.
So i wonder if this is way that joomla works that you can only have one default per template. but is it possible to have more than one?
any advice most welcome.
regards
w9914420
Sorry this got too long for a comment.
Okay let's start from the beginning. Templates have a set of parameters defined in the templateDetails.xml file. A template style is simple a record containing the information about a template and the array of parameter options you have selected. You can make as many template styles as you want for a given template Each one has its own name. In the menu you can select any of the styles and assign it to a menu item. ....
What you are talking about has nothing to do with template styles. You are talking about using a layout override for mod_menu. Because you are using a file with the same name as a core layout file you should get a 1:1 replacement.
From what I understand of what you want to do, you should instead make a new named replacemen both for default_separator and for default.php. THat's because the alternative layout field is going to look for a replacement for default.php say yourname.php and then in that replacement when you load a template called separator it is automatically going to look for yourname_separator rather than default_separator because it assumes you are appending the _separator to the base name. If you do this it has some advantages such as you will be able to make a more complex layout and it will allow you to load different sub layouts conditionally for example.
I think your are confusing template styles with the style for menu module. Unless you have a parameter in your template that specifies the choice of a mod_menu layout a template style is not going to help you.Go to he module manager and pick the module you want to apply the style to. Use the field to select the layout you want. Or if it is a css style use the style option. It could also be that what you really want is to apply module chrome. THat do can be done by editing the module. If you want to have the same menu with different layouts or styles you'll probably want to make additional modules for that menu.
I had a rethink of what i was trying to do. What I was trying todo could not be achieved through the method I hoped - creating a template for that one text separator would not be practical although I have now discovered how to feed template parameter values into layout overrides.
Thank you Elin for your time
regards w9914420

Joomla -- find all translations of a menu item

I am using Joomla 2.5 with the Language-Switcher Module and Plugin to built an multilingual site.
The main problem is: switching the language always leads to the translated homepage, but not to the translated menu-item., so I ran into the problem to find all translations of an Menu item.
Based on the internal Structure, the Language-filter only filters the page items with suitable language settings. So each menu item, or link, or url is unique and it is not possible to define something like a 'root' menu item for every translated menu item. Is it possible to create a Plugin that inserts a new button in the menu-item-creation-form?
Greeting philipp
Got it Working! Searching for "translations" did not lead to proper results, instead searching for "associations" solved it. I found the answer while looking into code of the com_menus files where is written:
$associations = MenusHelper::getAssociations( $active->id );
That's all, I just needed to register the MenusHelper class via:
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');

URLs for Joomla Component

I have created a simple basic component in joomla named, careerform so I want to know that what will be its url? Will it be :
index.php/?option=com_careerform
or in sef it will be something like:
index.php/components/careerform
or it will be like this while using .htaccess
/careerform
Is it true or what are joomla default URLs with different settings? Please tell what you know.
thanks for your time.
While what you are asking to do is possible, it would be rather complicated to rename a component. As part of the renaming you would have to update the names of dozens if not hundreds of classes throughout every file of the component. Very likely to run into some bugs because of this.
The far easier prospect is to just avoid these types of urls in your site. Joomla will only fall back to that style of url if a menu item does not exist for the view. Because of that, you can make the url into this:
http://sitename.com/any-component-alias/
To do this, go into the menu manager and create a new menu item. If you don't want this as part of the main menu, you can create a new menu. (I typically have a menu called "Hidden" for menu items that I want aliased but don't actually link to throughout the site from a menu.) When creating the menu item, make sure the type matches the component and view. The alias will then be whatever is entered in the alias box just below the title.
The one issue you may run into with this is that a component may not have a menu type for a particular view. In that case, you you would need to add the necessary metadata.xml file to the view (which again would be much easier than renaming the component!). A good tutorial for that can be found here: http://docs.joomla.org/Adding_view_layout_configuration_parameters.
yes if SEF will be enabled then index.php/component/careerform will be used.
You can create custom URLs by developing a router for your component.
There is very good documentation for it here.

Categories