Noodles Posted June 21, 2004 Posted June 21, 2004 I worked out a way of doing this. I would have replied to the other thread in here but it doesn't seem to have anything in it. in product_info.php: move $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_info = tep_db_fetch_array($product_info_query); to underneath $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_check = tep_db_fetch_array($product_check_query); Then change: <title><?php echo TITLE; ?> to: <title><? echo TITLE; if($product_check['total'] == 1){ echo " - " . $product_info['products_name']; } ?></title> And bingo, you've got your product name in your title; this should help with search engine optimisation as keywords in the title are valuable.
ZaphodQB Posted June 24, 2004 Posted June 24, 2004 Tried this and it did not work for Me. My Product Info page came up missing the all important "Product Info" Although I did make a much simpler method wich follows; In the bottom of the first <?php......?> block add these two lines of SQL code; $product_name_for_title_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_name_for_title_info = tep_db_fetch_array($product_name_for_title_query); Like so; <?php <snip> require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO); $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_check = tep_db_fetch_array($product_check_query); $product_name_for_title_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); $product_name_for_title_info = tep_db_fetch_array($product_name_for_title_query); ?> Then change the <title> tage as you suggested(using the newly created variable); <title><? echo TITLE; if($product_check['total'] == 1){ echo " - " . $product_name_for_title_info['products_name']; } ?></title>
Guest Posted July 7, 2004 Posted July 7, 2004 I found that a better way to do this is: Go to product_info.php Find this line: <title><?php echo TITLE ?></title> Change it to: <title><?php echo TITLE ?><?php echo $the_product_name; ?></title>
sinryder Posted August 30, 2004 Posted August 30, 2004 Find this line: <title><?php echo TITLE ?></title> Change it to: <title><?php echo TITLE ?><?php echo $the_product_name; ?></title> not working for me , any help :(
John Doswell Posted August 30, 2004 Posted August 30, 2004 Find this line: <title><?php echo TITLE ?></title> Change it to: <title><?php echo TITLE ?><?php echo $the_product_name; ?></title> not working for me , any help :( why dont you take a look in to your file where the product title is been displayed??? wait ill just look in to your files ... $products_name it should be! greetz john
Guest Posted August 30, 2004 Posted August 30, 2004 Oh, I do aplogize... I missed out the "S" in products. Yes, it SHOULD be: <title><?php echo TITLE ?><?php echo $the_products_name; ?></title>
mjm Posted September 3, 2004 Posted September 3, 2004 heh, i wrote a very basic function that pulls the item name & manufacturer name (important for my site) and puts that into the title & description tags. i have custom titles & descrptions for all my pages :) www.futureofstyle.com
Mickeyme Posted September 3, 2004 Posted September 3, 2004 heh, i wrote a very basic function that pulls the item name & manufacturer name (important for my site) and puts that into the title & description tags. i have custom titles & descrptions for all my pages :) www.futureofstyle.com Would it be possible to post this function or put it into a contribution package? Mickey
delinear Posted September 8, 2004 Posted September 8, 2004 That's just what I was looking for, thanks mikeyj. I had a few teething troubles with it though - I'm using STS templates and it doesn't work quite the same way. For anyone else using STS, this is how I got it working. First, I edited sts_display_output.php, look for the section: // BOF: WebMakers.com Changed: Header Tag Controller v1.0 // Replaced by header_tags.php if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) { require(DIR_WS_FUNCTIONS . 'clean_html_comments.php'); require(DIR_WS_FUNCTIONS . 'header_tags.php'); require(DIR_WS_INCLUDES . 'header_tags.php'); } else { echo "<title>" . TITLE . "</title>"; I changed the echo statement to the following (I wanted product names first then the store name): echo "<title>" .$add_title_products. " " . TITLE . "</title>"; But that still didn't quite work, I was getting html code in the title bar, span, br tags etc and I was getting the product code in square brackets (which I didn't need). To get around this I changed the echo line to the following (there's probably a more elegant way to do all this, but I need a quick and easy solution for the time being): $add_title_products = strip_tags($products_name); $add_title_products = explode("[", $add_title_products); $add_title_products = $add_title_products[0]; echo "<title>" .$add_title_products. " " . TITLE . "</title>"; Now it's working great, thanks again for the tip :)
Guest Posted September 8, 2004 Posted September 8, 2004 Actually, I was right the FIRST time. It IS: <title><?php echo TITLE ?> :: <?php echo $the_product_name; ?></title> I just checked it on my website. :blink:
Guest Posted September 8, 2004 Posted September 8, 2004 You can also dynamically make the HEADING TITLE of any page appear in the page title too. Go to any of your catalog pages. Find: <title><?php echo TITLE; ?></title> Change it too: <title><?php echo TITLE; ?> : <?php echo HEADING_TITLE; ?></title>
siavash Posted September 8, 2004 Posted September 8, 2004 doesn't work for me!! Did you try? Did you fail? No matter! Try again. Fail again! But fail better!
Guest Posted September 8, 2004 Posted September 8, 2004 That's strange... :blink: It works on my site. Go here to see it in action: http://www.getmemusic.com/product_info.php?products_id=39 ;)
siavash Posted September 8, 2004 Posted September 8, 2004 this is what i have done in product_info.php : <title><?php echo TITLE ?> :: <?php echo $the_product_name; ?></title> and nothing appears! my site: www.ciavash.com/shop Did you try? Did you fail? No matter! Try again. Fail again! But fail better!
Guest Posted September 9, 2004 Posted September 9, 2004 It doesnt work for me either Are you sure you guys arent assigning the variables somewhere else?? My install is pretty much stock as far as the header goes and I dont see where the variable is populated that early.
siavash Posted September 9, 2004 Posted September 9, 2004 mikeyj, what mods are u using to dispay category names and stuff? coz this might be the problem! unfortunately $the_product_name does not pull out anything for me. anybody? any ideas? Did you try? Did you fail? No matter! Try again. Fail again! But fail better!
Guest Posted September 9, 2004 Posted September 9, 2004 Sorry....I missed out a ; in both of them. (OOPS!) For Heading Title in the catalog pages change: <title><?php echo TITLE ?> : <?php echo HEADING_TITLE; ?></title> to: <title><?php echo TITLE; ?> : <?php echo HEADING_TITLE; ?></title> For Product Name in product_info.php change: <title><?php echo TITLE ?> :: <?php echo $the_product_name; ?></title> to: <title><?php echo TITLE; ?> :: <?php echo $the_product_name; ?></title> Sorry about that. What a difference a ; makes. :blink:
Guest Posted September 9, 2004 Posted September 9, 2004 Of course, if the PRODUCT NAME one still doesn't work for you guys after you do what I said above, I guess I must have a mod installed somewhere that's calling that variable.
Guest Posted September 9, 2004 Posted September 9, 2004 Aha! It could be THIS query, which is a modification: Try this . (I've placed the page title code underneath it in bold.) <?php$the_product_info_query = tep_db_query("select pd.language_id, p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_retail_price, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'" . " and pd.language_id ='" . (int)$languages_id . "'"); $the_product_info = tep_db_fetch_array($the_product_info_query); $the_product_name = strip_tags ($the_product_info['products_name'], ""); $the_product_description = strip_tags ($the_product_info['products_description'], ""); $the_product_model = strip_tags ($the_product_info['products_model'], ""); ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> <title><?php echo TITLE; ?> : <?php echo $the_product_name; ?></title>
siavash Posted September 9, 2004 Posted September 9, 2004 it's better now! a bit! what mod / contribution is that (the code not in bold)? Did you try? Did you fail? No matter! Try again. Fail again! But fail better!
Guest Posted September 9, 2004 Posted September 9, 2004 I'm not sure... ..I THINK it's some kind of dynamic meta tags contribution.
mjm Posted September 9, 2004 Posted September 9, 2004 rather than do that, why don't you just modify your includes/languages/english.php (what whatever language you are using) file to generate the dynamic titles. something like if ($PHP_SELF == "/product_info.php") { $Title = tep_get_products_name("$cPath"); } you can do that for all your pages. then at the bottom export that value to the TITLE define(TITLE, $Title); anyways, i found doing it that way pretty easy.
siavash Posted September 9, 2004 Posted September 9, 2004 Matt have you tested it yourself? does it work right? Did you try? Did you fail? No matter! Try again. Fail again! But fail better!
mjm Posted September 9, 2004 Posted September 9, 2004 it works for my store. here is a little snippet.... if ($_SERVER['REQUEST_URI'] == "/specials.php"){ $TitleTag .= "Reduced price items"; } if ($_SERVER['REQUEST_URI'] == "/brands.php") { $TitleTag .= "Clothing Brands"; } if ($TitleTag) { $TitleTag .= ", "; } $TitleTag .= "FOS Urban Clothing"; // define the actual title now define('TITLE', $TitleTag); www.futureofstyle.com
Recommended Posts
Archived
This topic is now archived and is closed to further replies.