Joomla 2.5: Remove breadcrumbs from specific pagesPublished: Tuesday, 27 August 2013 23:38 Written by Ogri Hits: 21353
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
-
133539
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-1. Transferring jDownloads and jComments -
65242
Joomla: Integrate reCAPTCHA v2 (NO CAPTCHA) into JComments -
37684
Editing animated GIF-images in Photoshop CS3 -
37038
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-2. Template, editor, and other extensions -
32424
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
-
lpay game online 11.08.2022 23:01
-
web site 11.08.2022 21:39
Hello, this weekend is good for me, as this moment i am reading this great informative piece of writing ...
-
homepage 11.08.2022 16:35
It's a pity youu don't have a donate button! I'd definitely donate to this brilliant blog! I suppose ...
-
homepage 11.08.2022 15:16
Hello There. I discovered your blog the usage of msn. That is a really smartly written article. I'll ...
-
-
Joomla: Integrate reCAPTCHA v2 (NO CAPTCHA) into JComments
-
gambling online 10.08.2022 16:31
It's amazing to pay a visit this site and reading the views of all mates concerning this article ...
-
-
Joomla: Merge two sites into one using component J2XML
-
ekonomi son dakika 11.08.2022 18:34
Today, I went to thhe beach with my kids. I found a sea shell and gave it to my 4 year old daughteer ...
-
ege güncel haber 11.08.2022 06:26
Unquestionably believe that which you stated. Your favorite reason seemed to be on the net the easiest ...
-
-
Migrating from Joomla 1.5 to Joomla 2.5. Introduction
-
ceri 138 11.08.2022 09:33
I'm gone to convey my little brother, that he should also pay a visit this website on regular basis to ...
-
-
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-2. Template, editor, and other extensions
-
PG SLOT เว็บตรง 10.08.2022 17:19
pg slot เว็บตรงมาแรงจนฉุดไม่อยู่ เล่นง่าย จ่ายทุกบิล ทำเทิร์นน้อยสำหรับโบนัส แล้วก็ โปรโมชั่นที่ท่านเลือก ...
-
-
Post an illustrated Joomla-site article on Facebook using OG-tags
-
Seo package Prices 11.08.2022 18:28
%% Stop by my blog post: Seo package Prices ...
-
Read more...