ADBLOCK_MSG
Social Media Buttons in Joomla 2.5. Selective placementPublished: Monday, 26 August 2013 18:24 Written by Ogri Hits: 10768
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
-
151609
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-1. Transferring jDownloads and jComments -
88288
Joomla: Integrate reCAPTCHA v2 (NO CAPTCHA) into JComments -
62713
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-2. Template, editor, and other extensions -
40787
Editing animated GIF-images in Photoshop CS3 -
40622
Custom 404 error page in Joomla 2.5
Login
Guest Column
Recent comments
-
Custom 404 error page in Joomla 2.5
-
Roseann
02.11.2020 08:17
-
-
Joomla: Merge two sites into one using component J2XML
-
www.cx5-forum.com
24.08.2020 03:52
you are in point of fact a excellent webmaster. The web site loading pace is incredible. It kind ...
-
-
Joomla: how to add your own language constants or override existing ones
-
Vouchersort
29.10.2020 11:33
Is this a free template that you are using as I really love it. As a website desugner myself I hope that ...
-
Voucher Sort
02.10.2020 00:07
Love this site keep up the good work!
-
-
Migrating from Joomla 1.5 to Joomla 2.5. Epilogue
-
Dewitt
11.02.2021 06:17
HELP. I can't write a comment without the page freezing.
-
-
Migrating from Joomla 1.5 to Joomla 2.5. Part 2-1. Transferring jDownloads and jComments
-
Francine
14.12.2020 08:49
I cant stomach this person so sorry x
-
Vouchersort
30.10.2020 15:43
Once again, great resource for us newbs.
-
Voucher Sort
30.09.2020 12:58
Is commenting still open?
-
motivational quotes
21.08.2020 13:12
Hi, all is going perfectly here and ofcourse every one is sharing information, that's really excellent ...
-
-
Unified filtering of mod_jcomments_latest module's output
-
Фильмы 2022 онлайн
03.12.2021 21:37
This web site definitely has all of the info I wanted about this subject and didn't know who to ask.
-
Read more...