Joomla 2.5: Remove breadcrumbs from specific pagesPublished: Tuesday, 27 August 2013 23:38 Written by Ogri Hits: 23362
Breadcrumbs, also known as site navigator, is useful Joomla module. And, as every module, it can be linked to all or only certain menu items. It is also possible to unlink this module from all or specific items. Many Joomla website owners wish to hide navigator on the home page, since it contains only one item "Home" with no link and does not incurs thus any functional load. Perhaps the site structure also provides other pages on which, for whatever reasons, it makes sense to hide navigator. The most typical example is a custom 404 error page, which, as I emphasize in the corresponding article dedicated to the rules of its creation and configuration, should fit into a site template, but at the same time to be by itself. Navigator on page 404 is not only unnecessary, but also ideologically harmful. We will consider this particular page as a special case, which describes the general principle of unlinking breadcrumbs from certain article.
The standard way to the module linking is not suitable here, since, as described in the above article, the menu item for the error page is not being created. In fact, such item can nevertheless be created (without binding it to a page, but only to link modules - such as breadcrumbs in our case). Then you can hide the navigator for this page by selecting On all pages except those selected in Module Assignment dropdown box on the page of editing module parameters in the site's admin interface. Such a method works well in this case; when adding new items to the different menues breadcrumbs will automatically get attached to them, so it is not required to do it manually every time (unlike the alternative Only on the pages selected; there it is necessary to manually add each created menu item to the module). However, its disadvantage is the need to create menu items for articles, even when there is no other need of this binding. All these menues are added as additional tabs in the Menu Selection sections of all modules, and interface becomes overloaded. This issue particularly reveals itself in case of multi-language, where you have to separately create a menu for each language, and, accordingly, the number of tabs in the module editing interface increases in proportion to the number of languages.
Given the above reasons, I prefer an alternative solution. Though it will require some skills of reading and editing PHP-code. Yet, if you are carefully following these instruction, the minimal knowledge is sufficient.
We will start, as always, with identification of the file and the place in its code, which will be edited. Breadcrumbs module has a separate position, which is set in the index.php
file of the active template. It is located in the folder templates\[my_template]
. Replace [my_template]
with the real name of your template's folder. Open the file for editing and find the occurrence of navigator module in its code. There are different options. For example, in templates Beez2 and Beez5 that are supplied with Joomla, the desired piece of code looks like this:
<div id="breadcrumbs"> <jdoc:include type="modules" name="position-2" /> </div>
In my custom template, whose structure was built in Artisteer, navigator is brought out using a special function artxPost, and its call in index.php
looks like this:
if ($view->containsModules('breadcrumb') echo artxPost($view->position('breadcrumb'));
In other templates the code of breadcrumbs may be different, but the general principle is to find the right place in the code by searching either the word "breadcrumb", or, if in your template the module is located in a position with less intuitively appropriate name - so search for this name. It's easy to ascertain module's position by opening its editing page in the administration service. Preview in template manager may also clarify module position (if to previously enable the Preview Module Positions option in its settings).
Now we assign a code to disable the output of the module according to our conditions. If you simply want to remove it from the home page, the criterion is:
JRequest::getVar('view') != 'frontpage'
Applying it to the first example (Beez2 or Beez5), substitute the following portion of code for the above one:
<div id="breadcrumbs"> <?php if (JRequest::getVar('view') != 'frontpage') { ?> <jdoc:include type="modules" name="position-2" /> <?php } ?> </div>
In the second example (template built in Artisteer) the modified code will be the following:
if ($view->containsModules('breadcrumb') && JRequest::getVar('view') != 'frontpage') echo artxPost($view->position('breadcrumb'));
We now return to the situation where you want to remove the navigator module from specific article pages. Consider the case of a multilingual site (namely - bilingual, like mine is at the time of this writing), and eliminate breadcrumbs on both English and Russian pages 404. At first find out IDs of corresponding articles. This is easily done by finding them in the list of articles in the admin service. In my case, the identifier of Russian page is 80, and the ID of the English one is 448. The following code fragments intended, as in the previous case, to replace the existing ones. Just replace my values of IDs with yours (read more about that construction in an article describing the methodology of selective output of social media buttons).
<div id="breadcrumbs"> <?php $article_id = explode(':', JRequest::getVar('id')); if (!(JRequest::getVar('view') == 'article' && ($article_id[0] == '80' || $article_id[0] == '448'))) { ?> <jdoc:include type="modules" name="position-2" /> <?php } ?> </div>
if ($view->containsModules('breadcrumb') && !(JRequest::getVar('view') == 'article' && ($article_id[0] == '80' || $article_id[0] == '448'))) { echo artxPost($view->position('breadcrumb'));
Using this technique you can hide the breadcrumbs on any other pages by simply adding their IDs to the clause. You can also invert the logics and remove the navigator from all articles other than those listed (details - ibid). And finally - it allows you to manipulate with other modules which allocated in separate positions in your web site's main template.
Latest News
-
Tuesday, 21 July 2020 03:18
Joomla 3: Redirect to same page after successful login -
Saturday, 30 December 2017 16:11
Joomla: how to add your own language constants or override existing ones -
Thursday, 30 November 2017 23:27
Joomla: Integrate reCAPTCHA v2 (NO CAPTCHA) into JComments -
Saturday, 25 June 2016 15:33
Unified filtering of mod_jcomments_latest module's output -
Thursday, 17 September 2015 16:23
Post an illustrated Joomla-site article on Facebook using OG-tags
Articles Most Read
-
142192
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-1. Transferring jDownloads and jComments -
73707
Joomla: Integrate reCAPTCHA v2 (NO CAPTCHA) into JComments -
43984
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-2. Template, editor, and other extensions -
38804
Editing animated GIF-images in Photoshop CS3 -
36245
Migrating from Joomla 1.5 to Joomla 2.5. Part 1. Transferring content
Login
Guest Column
Recent comments
-
Custom 404 error page in Joomla 2.5
-
king855 29.05.2023 10:21
-
-
Joomla: Content filtering by articles, categories and components
-
sbobet singapore 29.05.2023 02:27
Join the sbobet online sports betting & casino today. Place sports and casino bets confidently - get ...
-
-
Joomla: Integrate reCAPTCHA v2 (NO CAPTCHA) into JComments
-
오피쓰 30.05.2023 00:00
certainly like your web site however you have to test the spelling on quite a few of your posts. A ...
-
바카라사이트 29.05.2023 02:26
What i Ԁo not realize is іn truth how үοu are not actսally a lot mkre smartly-appreciated tһan yoᥙ ...
-
sbobet slot 28.05.2023 13:05
Spot on with this write-up, I actually think this amazing site needs far more attention. I'll probably ...
-
-
Migrating from Joomla 1.5 to Joomla 2.5. Introduction
-
바카라사이트 29.05.2023 11:30
Тhanks in suppor ߋf sharing ѕuch a fastidious opinion, post іѕ gօod,thatѕ ԝhy i have reаd iit entіrely ...
-
-
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-2. Template, editor, and other extensions
-
evolution casino 29.05.2023 20:09
Also visit my site; evolution casino ...
-
mega888 online 29.05.2023 16:02
Play the latest online casino games at mega888 and win big. Experience fun, thrilling, and exhilarating ...
-
tricks to baccarat 28.05.2023 12:15
Also visit my website ... tricks to baccarat: https://baccaratsg.com/
-
-
The structure of internal links within Joomla site
-
สล็อต 28.05.2023 08:07
4Jokers Casino เป็นสถานที่ที่สมบูรณ์แบบสำหรับการเล่นและรับรางวัลใหญ่! ด้วยสล็อต: https://4jokerscasino.com/ ...
-
Read more...