Jump to content

Newbie - Making an image a link


DarrenG

Recommended Posts

Hi

 

I am new to php and have inherited some code to change. At the moment I have a page that has an icon and then some php that generates text that is a link to filter a list. I now need to remove the text and make the icon the link. Any ideas how this would be done?

 

Here is the current code snippet:

 

<?php

$logo_size = array(18, 17);
$logo_image = "";

echo $html->image('icons/new.png', array(
'alt'=>'New Product Icon',
'width'=>$logo_size[0], 
'height'=>$logo_size[1],
'border'=>'0',
'class'=>'ProductLogo'));

$queryString_newproducts = str_replace("data[Product][check_1]=&", "data[Product][check_1]=1&", $queryString);
echo $paginator->sort(' New Product', 'product', array('url'=>array('?'=>$queryString_newproducts)));

?>

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

Well, I don't recognize what you're using to create that $html object, but looking at the code you listed makes me think you may be able to do something like this:

echo $html->image('icons/new.png', array(
'alt'=>'New Product Icon',
'width'=>$logo_size[0], 
'height'=>$logo_size[1],
'border'=>'0',
'onclick'=>'window.location=\'somepage.php\'',
'style'=>'cursor:pointer;',
'class'=>'ProductLogo'));

Link to comment
Share on other sites

I forgot to mention that it was written in cakephp. Would that make a difference.

The page displays a list of products and some are New. Clicking the link should just display the new items only and remove all others.

 

Don't know if any of this helps.

Link to comment
Share on other sites

I did and it made the icon a link. The only issue I have now is trying to get that link to work and filter the correct results. I'm trying to learn quick, just like other newbies I guess  :-\

 

Any thoughts on how I could apply the correct code to the link?

Link to comment
Share on other sites

From what I can gather the first part of the php code is for the image. Then the next 2 lines generate the filter and paginate it on the screen:

 

<?php

...

$queryString_newproducts = str_replace("data[Product][check_1]=&", "data[Product][check_1]=1&", $queryString);
echo $paginator->sort(' New Product', 'product', array('url'=>array('?'=>$queryString_newproducts)));

?>

 

I think I need to somehow get these 2 lines of code to work on the image icon. If I'm way off the mark I apologize but I think that is what I need to do.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.