Solved

Make PHP image a link

Posted on 2011-02-14
6
457 Views
Last Modified: 2012-05-11
Hi.  I have a Joomla site and have added the following code to the main index.php file to add the social networking buttons to it, however not being familiar with PHP, I don't know how to make those images clickable and add the URLs.  Also need to make sure the URL target is blank so that people don't leave the website and a new web page is opened.  Any help would be great.
Thanks!
<div class="social"><p>Follow Us</p><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/images/twitter.png" border="0" alt="<?php echo JText::_('Twitter'); ?>" width="15" height="19" /><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/images/facebook.png" border="0" alt="<?php echo JText::_('Facebook'); ?>" width="22" height="22" /></div>

Open in new window

0
Comment
Question by:kmurphychi
6 Comments
 
LVL 8

Accepted Solution

by:
PranjalShah earned 250 total points
ID: 34891018
Here is an example for twitter..you can do the same for facebook...Surround your <img> tag with the <a href> tag...


<a href="http://www.twitter.com" target="_blank">
<img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/images/twitter.png" border="0" alt="<?php echo JText::_('Twitter'); ?>" width="15" height="19" />
</a>
0
 

Assisted Solution

by:jayadevneduvachalil
jayadevneduvachalil earned 250 total points
ID: 34891067

Please try this
<div class="social"><p>Follow Us</p><a href="http://www.twitter.com" target="_blank"><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/images/twitter.png" border="0" alt="<?php echo JText::_('Twitter'); ?>" width="15" height="19" /></a><a href="http://www.facebook.com" target="_blank"><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/images/facebook.png" border="0" alt="<?php echo JText::_('Facebook'); ?>" width="22" height="22" /><a/></div>

Open in new window

0
 

Author Closing Comment

by:kmurphychi
ID: 34891145
Thank you!
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 5

Expert Comment

by:lazysheepmedia
ID: 34891154
why dont you use one of the many social plugins - All the hard ork is done for you
0
 
LVL 4

Expert Comment

by:Cristi_E
ID: 34891158
Hi,
Just try to put it in a link like this:

 
<div class="social">
	<p>Follow Us</p>
	<a href="http://twitter.com/"><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/images/twitter.png" border="0" alt="<?php echo JText::_('Twitter'); ?>" width="15" height="19" /></a> 
	<a href="http://www.facebook.com/"><img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template;?>/images/facebook.png" border="0" alt="<?php echo JText::_('Facebook'); ?>" width="22" height="22" /></a>
</div>

Open in new window


Just follow the tutorial on how to create a link:
See: HTML Hyperlinks (Links)

Cristi
0
 
LVL 5

Expert Comment

by:lazysheepmedia
ID: 34891161
sorry submitted after you accepted the above - ah well :)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question