Solved

Make PHP image a link

Posted on 2011-02-14
6
455 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

First of all, we will need Jumi component or Sourcerer plugin for this to work. We need either of these because the main focus here is custom development outside of the standard modules or articles within Joomla. You can find Jumi here...it's my …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now