How to create a link to an article in joomla?

2019-07-31 03:14发布

问题:

My website contains some icons, I want that each icon point to a link to an article, I have already create those articles, I want to show them without creating menu items. I tried to do that :
Href of icon1 -> Article 1
Href of icon2 -> Article 2
... But my target page show only the text of the article, without the slider and the main menu of the website.
What works for me :
I have created a menu called hidden with menu items, I matched each menu item with the article that I want, then I added the link of the article in my href's icon.
Menu item 1 -> hidden/item1 and I selected Article 1
Menu item 2 -> hidden/item2 and I selected Article 2.

Thank you.

回答1:

If you want to keep the desired modules, you need to specify a menu item. This is because you want to have control over what modules should be displayed with what articles, as modules are assigned by menu items. If there is no menu-item specified by purpose, then the wrong modules will be displayed or no modules at all.

So, best way to achieve this is to create a separate menu and the respective menu items for each of your articles. You can name this menu as "Hidden", since you will not want to create a module and display it at the front-end. Then you can link your icons to each article including the menu item id in the url: Example of the url:

index.php?option=com_content&view=article&id=1&Itemid=100

If your icons are inside a custom html module, then I would suggest to use the link manager of the JCE editor to link to your menu items/articles.

If you are linking from inside your template, then you might want to use the JRoute() to create the link, to ensure SEF urls if you enable them...

So the code for the link would look like:

<a href="<?php echo JRoute::_('index.php?option=com_content&view=article&id=1&Itemid=100'); ?>">Link</a>