Jump to content

simple links in PHP


stc1

Recommended Posts

Hi all,

 

This is my first post here. I know its super basic but im just trying to get to grips with php as i am customizing an osCommerce site. I have been trying to get the page to write 'you have x item(s) in your cart', and make the whole sentence a link to the shopping cart page. I have been playing around with the code but i just cant get it to work. can anyone help. This is as far as i have got so far...

 

	$cart_contents_string .= '</table>';
  } else {
    $cart_contents_string .= BOX_SHOPPING_CART_EMPTY;
  }

  $info_box_contents = array();


if ($cart->count_contents() == 1)
{ 
$info_box_contents[] = array('text' => $cart->count_contents(). '.<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . 'items in your cart');
} else{


  $info_box_contents[] = array('text' => '<table style="">'.$cart->count_contents(). '.<a href="' . tep_href_link(FILENAME_SHOPPING_CART) . 'items in your cart</table>');
}

 

Its just the last two lines i've been messing around with, but ive included a few lines above for context. I've also attached the whole file, from before i started editing it, should this help. Any help would be really appreciated. Thanks.

 

Matt

 

Matt

18544_.php

Link to comment
https://forums.phpfreaks.com/topic/263820-simple-links-in-php/
Share on other sites

If tep_href_link returns a completed anchor tag then it won't be possible to make the entire text a hyper-link using that method.

 

If however, it just returns a URI than you should use the following

 

$info_box_contents[] = array('text' => '<a href="'.tep_href_link(FILENAME_SHOPPING_CART).'">There are '.$cart->count_contents().' items in your cart</a>');

 

If "text" is your only array key you may also want to consider removing the array entirely and just having:

 

$info_box_contents[] = '<a href="'.tep_href_link(FILENAME_SHOPPING_CART).'">There are '.$cart->count_contents().' items in your cart</a>';

Link to comment
https://forums.phpfreaks.com/topic/263820-simple-links-in-php/#findComment-1351976
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.