WhatsApp Share Button

syhussaini

New Member
Dear Team,

I am planning to have a WhatsApp share button above and below every list to be shown on mobile devices. I currently have this code:

PHP:
      <!--WhatsApp Share Starts-->
              <?php
       if($this->config->whatsapp) {
            $label = JText::_('WHATSAPP_SHARE');       
            echo '<a href="whatsapp://send?text='.$item->title.'&nbsp;:&nbsp;'.rawurlencode(JURI::getInstance()->toString()).'" class="jomcl_wa_btn jomcl_wa_btn_l">'.$label.'</a>';
        }
        ?>
      <!--WhatsAppshare-->

I am not sure where to place this code in order to have it displayed on the top and bottom of my list. Kindly help me please.

Website Link: http://jobwalkins.in

Looking forward to hearing from you soon.

Best Regards,
Syed H
 
If you don't mind adding it to every list, you can out it in the List intro/outro fields.

Otherwise there is almost certainly a way to add it to the list template as an override, but I will leave that to others as I don't use overrides myself.
 
Where did you get that code from? The $this->config->whatsapp is not something which is going to "just work". Are you running a Whatsapp share extension / plugin?

-- hugh
 
Dear Hugh,

You are absolutely right, it did not work. But, I am surprised when I find it working in the other sections of the same site under JomClassifieds Adverts. Click here to see it in action (you will have to enable responsive mode and view in Mobile Layout to see it live). It is designed to show up only in mobiles I guess and that is why we need to view it mobile layout to make it visible.

Can you please advice?

Best Regards,
Syed H
 
Dear Hugh,

You are absolutely right, it did not work. But, I am surprised when I find it working in the other sections of the same site under JomClassifieds Adverts. Click here to see it in action (you will have to enable responsive mode and view in Mobile Layout to see it live). It is designed to show up only in mobiles I guess and that is why we need to view it mobile layout to make it visible.

Can you please advice?

Best Regards,
Syed H
Well, it's looking at $this, which is entirely context dependent, referring to the class the code is running in. And it's referring to $item, which again is something specific to wherever this code originally ran.

You'd need to figure out what you want $item to be in the context of a Fabrik list.

I think you can just get rid of the config check.

Hugh

Sent from my HTC6545LVW using Tapatalk
 
There are ways in Joomla for detecting mobile devices.
See this thread in Stackoverflow...
Need to detect mobile browser and load mobile.css file for Joomla template with PHP

It looks like, in J3.4+ anyhow - and once you figure out just what $item comes from - all you need is
PHP:
if (JFactory::getApplication()->client->mobile) {
    $label= JText::_('WHATSAPP_SHARE'); 
    echo'<a href="whatsapp://send?text='.$item->title.'&nbsp;:&nbsp;'.rawurlencode(JURI::getInstance()->toString()).'" class="jomcl_wa_btn jomcl_wa_btn_l">'.$label.'</a>';
}

Personally, I would just do this with javascript (of course:p)
3 ways to detect mobile device in jQuery
JavaScript:
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
// You are in mobile browser - js/jQuery code here
}
So long as what you reference in your php code as '$label' and '$item->title' are included in the DOM on the page - why not let the browser do the work and pull them out and insert what you need into the url (built via javascript)?
 
Last edited:
Hello Team,

Thank you for extending this warm help. I deployed WhatsApp along with other social buttons using the ShareIt code.
Added the main script in the HEAD section of my Helix Framework and the as suggested by Sophist, I added the DIV blocks of ShareIt in Intro/Footer of the list.
It now shows in desktop also which I guess Looks beautiful with all those colorful icons.

I Thank you all again.

Best Regards,
Syed H
 
That's the beauty of Joomla. Why I didn't suggest a 3rd party social media plugin is beyond me. I have one installed myself - just was not aware you could add to it (or that WhatsApp was included). There's a lot of cool 3rd party Joomla apps 'out here' - so many that my head spins every time I try to 'go shopping' for one.:confused:
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top