help needed to modify some php code

Discussion in 'PHP' started by johntrade, Jul 12, 2010.

  1. #1
    Hi,

    I have this script and the meta descriptions for the products are the product title and the homepage meta tag, eg this is how my site looks in google for a product:

    Werewolf 1/8th 50mph Brushless Rc Buggy <<<title>
    3 May 2010 ... Werewolf 1/8th 50mph Brushless Rc Buggy, Electronic and Rc Toys - NitroWorld - Remote Control Hobby Models.

    I want to keep the title of the product in the tag but the highlighted section above I want it to pull the first 150 characters or so from the actual product description so they're not all the same.

    the php code i have is below which is from the index.php

    // ---------- prod page
    	case "product":
    	$body->assign("META_TITLE",$row_product["prodName"]);
    	$body->assign("META_KEYWORDS",$row_product["prodName"].', '.$row_product["prodBrand"].' '.$row_product["prodCategory"].', '.$configTitle['value']);
    	$body->assign("META_DESCRIPTION",$row_product["prodName"].', '.$row_product["prodBrand"].' '.$row_product["prodCategory"].' - '.$configTitle['value']);
    	$body->assign("PAGETITLE",'<h1>'.$row_product["prodName"].'</h1>');
    		if (isset($_GET['savelink'])) {
    		$body->assign("NOINDEXTAG",'<meta name="robots" content="noindex,nofollow" />');
    		}
    	include("includes/singleproducts.inc.php");
    	$body->assign("PRODS",$box_content);
    	include("includes/comments.inc.php");
    	$body->assign("COMMENTS",$box_content);
    	include("includes/addcomments.inc.php");
    	$body->assign("ADDCOMMENTS",$box_content);
    	include("includes/compareproducts.inc.php");
    	$body->assign("COMPAREPRODS",$box_content);
    	include("includes/products.inc.php");
    	$body->assign("SIMILARPRODS",$box_content);
    	$body->assign("MIDSTYLE",'content-a');
    	$body->assign("FLOATSTYLE",'content-float-right-a');
    	$body->parse("body.sideNavRight");
    	break;
    PHP:
    Any help would be very much appreciated, hope i've made my problem clear enough.

    John
     
    johntrade, Jul 12, 2010 IP
  2. Deacalion

    Deacalion Peon

    Messages:
    438
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    When you say 'pull', do you mean remove the first 150 characters or use them for the description?

    something like:
    $shortDescr = substr($row_product["prodDescr"], 0, 150);
    Code (markup):
    Then add that to the assign method.
     
    Deacalion, Jul 13, 2010 IP