As mentioned, we recommend you use the non-sef url inside the {component}
tag. But getting that url is not that straight-forward for some components.
Let's take the Weblinks Component as an example. And let's say we want to show all weblinks from category with id 2
.
When editing the weblinks in the administrator, we can see option=com_weblinks
in the url. So we know the name of the component that follows option
.
Since we want to view a category, we could guess that the view
part will be category
. But that's just guessing. So we don't know if the urls should be index.php?option=com_weblinks&view=category&id=2
or index.php?option=com_weblinks&view=cat&cid=2
, or something else. The logic behind the urls differs per component.
So how do we find the correct URL?
Well, the easiest way to get a component URL is to create a Menu Item.
When creating a menu item, we need to select the desired component as "Menu Item Type". In this case, we select List Web Links in a Category
- and then select the category we want to use. After saving it, we will see the correct url in the Link
field:
So the plugin tag to use will simply be:
{component url="index.php?option=com_weblinks&view=category&id=2"}
You could now hide the menu item, or even delete it, as the url used in the {component}
tag is not connected to that menu item - we just needed it to know what url to use.
Component parameters
However, in many cases you do want and need a menu item. Because you want to be able to control the extra settings that come with the component.
When using the basic url index.php?option=com_weblinks&view=category&id=2
, the component will show the requested category, but will use the default settings for everything else.
To control the settings of a component - such as whether or not to show the category title and description, whether or not to show subcategories, etc - you need a menu item.
So we'll keep this menu item and set the extra settings we need. However, the plugin tag we used in above example still doesn't use that specific menu item. It is still just using the default component settings.
To tell Components Anywhere to use the desired menu item, we need to add the menu item ID to the url inside the plugin tag. We do this by using the Itemid
parameter.
To find the menu item ID, just look in the menu items list (ID is on the right) or look in the url when editing the menu item in question:
So in this example the menu item it is 123. Than means the full url to use is:
{component url="index.php?option=com_weblinks&view=category&id=2&Itemid=123"}
Now, any changes you make to that menu item settings will also be reflected in the output of the Components Anywhere tag.
Note: Make sure the Menu Item is "Published" and its Access Level is set to "Public". If you do not want the menu item to show up in your website menus, in the menu item settings under "Link Type", you can set the "Display in Menu" option to "No".