Solved

Make PHP image a link

Posted on 2011-02-14
6
460 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
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.

724 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