Social Media Buttons in Joomla 2.5. Selective placementPublished: Monday, 26 August 2013 18:24 Written by Ogri Hits: 9987
Social Media Buttons in Joomla 2.5
Where to embed?
Different types of button bars
Share42 horizontal panel
Share42 floating vertical panel
Selective placement
While writing an article about the customization of page 404, I raised the issue of how to get rid of unwanted items in a page interface. Another article is devoted to the selective hiding of the breadcrumbs module. I also came to the conclusion not to display social buttons on page 404. There are other cases where it's worth to hide social media icons on certain pages, or vice versa - to display them only on some. Arranging articles of this series, I just faced a similar need: some button panels are displayed for illustration only in the relevant articles. So I decided to add this topic to the series.
So, let's specify a condition to filter the output of the buttons panel. If the goal is to display it only on the pages of certain articles, then for each of them it takes the following form:
$article_id = explode(':', JRequest::getVar('id')); if (JRequest::getVar('view') == 'article' && $article_id[0] == '[Article ID]') ...
The value of [Article ID]
can be easily determined in the list of articles, or else in the edit article interface - both in the administrative service. Accordingly, for hiding the buttons on some pages the negation operator !
is being added to the above construction.
Thus, the code of the button bar that is inserted into the file of article template as described in the first article of this series, is framed with conditional statement if
. For example, on my bilingual website IDs of Russian and English pages 404 are 80 and 448 respectively. The code snippet of the social buttons panel is as follows:
<?php $article_id = explode(':', JRequest::getVar('id')); if (!(JRequest::getVar('view') == 'article' && ($article_id[0] == '80' || $article_id[0] == '448'))) { ?> /* =====> !!! Script of social media buttons is HERE */ <?php } ?>
Replace 80 and 448 with values of your pages' identifiers. By the way, if anyone interested, when SEF is enabled, the condition might look simpler:
if (JRequest::getVar('id') == '[Article ID]') ...
Hopefully you have been using SEF, but certainly there are cases when Joomla users are turning it off for one reason or another. And if in the former case JRequest::getVar('id')
returns an identifier string, then in the second it returns the same, but with the article's alias as a considerable adjunct. The alias is separated from the number by a colon. For instance, when SEF is on, the string of this article's ID is '723'
, otherwise it would be '723:social-media-buttons-in-joomla-2-5-selective-placement
'. Function explode
has being included to make the condition universal for both options, and it guarantees you can disable SEF with no hidden side effects in the logic of the output of social service buttons in your Joomla web site pages.
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 -
73709
Joomla: Integrate reCAPTCHA v2 (NO CAPTCHA) into JComments -
43985
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...