8

I created 2 front-end views. One view is to list the records and an another view to edit a particular record.

The first view name is 'products' which shows the list of products from the table. In the default.php while forming the list of products I formed the anchor link like index.php?option=com_productman&view=product&product_id=xfor each row.

The second view name is 'product' where it gets the product_id from URL and shows the individual product.

  1. I am not sure whether this is the right way of doing.
  2. There is no separate Itemid for the product view because it is not launched from Joomla menu item.
  3. The breadcrumbs are not showing properly.

Can someone advice whats the correct way of developing front-end views.

1 Answer 1

5

It is the right way :-) Build your links with JRoute, for example:

JRoute::_('index.php?option=com_productman&view=product&product_id=x');

It will automatically append the menu item ID of your list page. I assume you have a menu item for the products view? If not then you have to add a menu type for it.

You could also make a menu type for the product detail page and make a hidden menu entry to it in the backend and then use that item id in your links, example:

JRoute::_('index.php?option=com_productman&view=product&product_id=x&Itemid=123');

The breadcrumbs will be build depending on your menu structure by default. So if your item ID is set right, you will also have some basic breadcrumbs. You can also build the breadcrumbs by yourself in the view: https://docs.joomla.org/J3.x:How_to_add_breadcrumbs

1
  • Agree on the JRoute. It makes sense if we have only 2 views where one view products is attached on a menu and the other view product is via JRoute. I have few URLs in product view takes to other views. Product view is not a valid menu item because its metadata.xml is configured as hidden="true" so there is no way a hidden menu item can be created. If we are jumping to a third view then there is no Itemid. I referred the breadcrumb document and add my own link and I noticed that breadcumbs is also working based on the menu Itemid. Commented Oct 1, 2015 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.