DarrenG Posted June 14, 2010 Share Posted June 14, 2010 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. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted June 14, 2010 Share Posted June 14, 2010 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')); Quote Link to comment Share on other sites More sharing options...
DarrenG Posted June 14, 2010 Author Share Posted June 14, 2010 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. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted June 14, 2010 Share Posted June 14, 2010 I know nothing about cakephp, but did you try what I posted? Quote Link to comment Share on other sites More sharing options...
DarrenG Posted June 14, 2010 Author Share Posted June 14, 2010 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? Quote Link to comment Share on other sites More sharing options...
F1Fan Posted June 14, 2010 Share Posted June 14, 2010 I have no idea what code you're talking about. Something to do with the query string? Quote Link to comment Share on other sites More sharing options...
DarrenG Posted June 14, 2010 Author Share Posted June 14, 2010 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. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted June 14, 2010 Share Posted June 14, 2010 Is this in a loop or something? All I know to tell you is that you can just add "?someVariableName=someVariableValue" to the end of the "somepage.php" to pass variables to the new page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.