Aller au contenu

Métas et oscommerce


michmuch51

Sujets conseillés

Un grand et gentil modérateur du hub à dit un jour:

Il y a sur ce forum un certain nombre de prestataires pour lesquels oscommerce n'a plus de secrets. Si tu as des questions, donc, n'hésites pas

Anonymus si tu ne te reconnais pas là c'est pas ma faute :D

Alors là je me suis suis dit mais c'est biensure, je galère sur mon pb tout seul isolé loin des lumières du HUB :lol:

Alors voilà ma question m'accompagnant moi et mes grands sabots...

Comment fait on pour insérer des métas dynamiques en fonction des produits sur osco??

Alors avec un peu de naïveté je me suis dit "Bababba une petite demi heure (en étant large) et c'est installé...

Alors j'ai trouvé ca:

HeaderTags_V_2.4.4

Et dans cette contrib je suis tombé la dessus:

// WebMakers.com Added: Header Tags Controller v2.0

// by Linda McGrath oscommerce_at_WebMakers.com

// Based on v2.2 snapshot 6-22-2002

// Updated by Oswaldo Herrera <waldosoc_AT_yahoo.com.mx>

// Updated by Talon177 (28 March 2004)

Please read carefully and backup your programs before adding.

This has been written for the current 2.2 and is up to date through snapshot 6-22-2002

This add-on allows you to have a unique TITLE, KEYWORDS and DESCRIPTION in the <head> tag for all pages and each product.

You can see this in use at:

http://www.thewebmakerscorner.com/theshop

http://www.incendio.com.mx/catalog

Includes: Language Support

Admin Function has been written as a contribution by Richard Fielder

================================================================================

=====================

TABLE CHANGES:

This was ok to me (wdo):

Add the following code to your database or import "header.sql" (Talon177)

OR copy the included database_setup.php file to your root directory (where your

index.php file is located).  Then open your browser and type in

http://www.yoursite.com/database_setup.php (substitute your url of course). You

should delete this file from your site once you are done.

ALTER TABLE products_description ADD products_head_title_tag VARCHAR(80) NULL;

ALTER TABLE products_description ADD products_head_desc_tag LONGTEXT NULL;

ALTER TABLE products_description ADD products_head_keywords_tag LONGTEXT NULL;

ALTER TABLE categories ADD category_head_title_tag VARCHAR(80) NULL;

ALTER TABLE categories ADD category_head_desc_tag LONGTEXT NULL;

ALTER TABLE categories ADD category_head_keywords_tag LONGTEXT NULL;

================================================================================

=====================

NEW FILES TO ADD:

Added Files:

/catalog/includes/header_tags.php

/catalog/includes/languages/english/header_tags.php

/catalog/includes/languages/espanol/header_tags.php

/catalog/includes/functions/clean_html_comments.php

/catalog/includes/functions/header_tags.php

================================================================================

=====================

MODIFICATIONS TO FILES:

Add to /catalog/includes/application_top.php at the end of

the file right before the last ?>

// BOF: WebMakers.com Added: Header Tags Controller v1.0

  require(DIR_WS_FUNCTIONS . 'header_tags.php');

// Clean out HTML comments from ALT tags etc.

  require(DIR_WS_FUNCTIONS . 'clean_html_comments.php');

// Also used by: WebMakers.com Added: FREE-CALL FOR PRICE

// EOF: WebMakers.com Added: Header Tags Controller v1.0

NOTE: if already using FREE-CALL FOR PRICE Add-on you do not need to add the clean_html_comments.php to application_top as you should already have it there.

================================================================================

=====================

CHANGES TO ALL FILES:

Changes in all files in /catalog containing: <title><?php echo TITLE; ?></title>

Modify a line in all files ( approximately 35 files ) where there is a <TITLE> tag:

These files are located in /catalog

A search for <title><?php echo TITLE; ?></title> will locate all the files needing a change.

NOTE: The <TITLE> tag is different in popup_image.php and is not handled by Header Tags Controller.

In each file of /catalog/ you will need to make the following modification:

Replace the existing two lines in all files that you want to use the Header Tags Controller:

Old Lines:

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">

<title><?php echo TITLE ?></title>

New Lines:

<?php

// 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_INCLUDES . 'header_tags.php');

} else {

?>

  <title><?php echo TITLE; ?></title>

<?php

}

// EOF: WebMakers.com Changed: Header Tag Controller v1.0

?>

NOTE: Rather than remove the original line, I used this block of code that uses the standard TITLE if the header_tags.php file does not exist.

================================================================================

=====================

In stylesheet.css, add the following. Set it to the desired size for your shop.

h1 {

font-family: Verdana, Arial, sans-serif;

font-size: 20px;

font-weight: bold;

}

================================================================================

=====================

Find the following lines in index.php

Around line 70:

Find

    if ($category_depth == 'nested') {

    $category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");

and replace with

    if ($category_depth == 'nested') {

    $category_query = tep_db_query("select cd.categories_name, c.categories_image, c.category_head_title_tag, c.category_head_desc_tag, c.category_head_keywords_tag from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");

=============================================

Around line 78:

Find

    <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

and replace it with

    <td><h1><?php echo $category['category_head_title_tag']; ?></h1></td>

=============================================

Around line 239:

Find

    ?>

    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

      <tr>

        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

          <tr>

            <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>

and replace it with

    $category_query = tep_db_query("select c.category_head_title_tag from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "'");

    $category = tep_db_fetch_array($category_query);

    ?>

    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="0">

      <tr>

        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">

          <tr>

            <td><h1><?php echo $category['category_head_title_tag']; ?></h1></td>

The catalog section should now being installed and working!  However, if the admin section

has not been installed, some page heading may be missing. This is just temporary and, in

fact, shows that the installation is working so far. :)

================================================================================

=====================

USE OF HEADER TAGS GENERATOR

How you want each page to handle the Header Tags is defined in /includes/header_tags.php

What definitions you want used with each page is defined in /includes/languages/english/header_tags.php

You can modify which pages use what by looking at the samples setup in these two files.

Be careful if editing or changing /catalog/includes/header_tags.php and watch for == vs !=

NOTE:

HTTA - means Header Tag Title All

HTKA - means Header Tag Keywords All

HTDA - means Header Tag Description All

To add a new page (shows how to add header_tags ode for contact_us page):

1 - open incldues/languages/english/header_tags.php, find this block of code, copy it

  and paste it somewhere else in the file:

  // index.php

define('HTTA_DEFAULT_ON','1'); // Include HEAD_TITLE_TAG_ALL in Title

define('HTKA_DEFAULT_ON','1'); // Include HEAD_KEY_TAG_ALL in Keywords

define('HTDA_DEFAULT_ON','1'); // Include HEAD_DESC_TAG_ALL in Description

define('HEAD_TITLE_TAG_DEFAULT', '');

define('HEAD_DESC_TAG_DEFAULT','');

define('HEAD_KEY_TAG_DEFAULT','');

Then change all occurrences of DEFAULT to the name of your page. For example, if you want

to add a contact_us page, it would be CONTACT_US.

2 - open includes/header_tags.php and find this block of code, copy it and paste it

  somewhere else in the file:

  // about_us.PHP - was default.php

case (strstr($_SERVER['PHP_SELF'],FILENAME_ABOUT_US) or strstr($PHP_SELF, FILENAME_ABOUT_US) ):

$tags_array = tep_header_tag_page(HTTA_ABOUTUS_ON, HEAD_TITLE_TAG_ABOUTUS,

                                  HTDA_ABOUTUS_ON, HEAD_DESC_TAG_ABOUTUS,

                                  HTKA_ABOUTUS_ON, HEAD_KEY_TAG_ABOUTUS );

break;

Then change all occurrences of ABOUTUS to CONTACT_US.

The title for your contact us page should now work.

:fou::fou::fou:

:huh: Rassurez moi y a plus simple à installer quand même faut pas tout que je me tape manuellement!!!! :dots:

Lien vers le commentaire
Partager sur d’autres sites

Merci, j'ai trouvé un échappatoir qui marche tip top, voici la soluce ca évitera aux autres de chercher:

INSTRUCTIONS:

1. Open your product_info.php file.

Find this (line 1):

<?php

/*

  $Id: product_info.php,v 1.92 2003/02/14 05:51:21 hpdl Exp $

  osCommerce, Open Source E-Commerce Solutions

  http://www.oscommerce.com

  Copyright © 2003 osCommerce

  Released under the GNU General Public License

*/

  require('includes/application_top.php');

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);

?>

And add this directly below it:

<?php

//begin dynamic meta tags query -->

$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_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'], "");

$the_manufacturer_query = tep_db_query("select m.manufacturers_id, m.manufacturers_name from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on (m.manufacturers_id = mi.manufacturers_id and mi.languages_id = '" . (int)$languages_id . "'), " . TABLE_PRODUCTS . " p  where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.manufacturers_id = m.manufacturers_id");

$the_manufacturers = tep_db_fetch_array($the_manufacturer_query);

// end dynamic meta tags query -->

?>

2. Directly below the <head> tag within this page (roughly line 39 after pasting the above), copy and paste this:

<?php

//begin dynamic meta tags query -->

?>

<title><?php echo $the_product_name; ?>: <?php echo TITLE ?></title>

<meta name="keywords" content="<?php echo TITLE ?>, <?php echo $the_product_name; ?>, <?php echo $the_product_model; ?>, <?php echo $the_manufacturers['manufacturers_name']; ?>">

<meta name="description" content="<?php echo $the_product_description . "," . $the_product_name; ?>">

<?php

//end dynamic meta tags query -->

?>

KNOWN BUGS:

----------------------

The recent addition of the "stripped tags" coding does remove all HTML EXCEPT:

1. Bulleted lists: It seems to add the following into the description tag in place of the bullets:

2. Other Characters: Tested with ©, symbols and seemed to work okay.

----------------------

C'est une autre contrib en fait ;)

Lien vers le commentaire
Partager sur d’autres sites

:blink: Tu avais une question, ou tu postais juste pour dire bonjour ??

Parce que je ne suis pas sûr d'avoir compris le but de ta requète :wacko:

Désolé :huh:

Lien vers le commentaire
Partager sur d’autres sites

Comment fait on pour insérer des métas dynamiques en fonction des produits sur osco??

C'était ca ma question :blink: J'ai peut être manqué de clarté ds ma demande :whistling:

Anyway j'ai trouvé ma réponse :fete:

Lien vers le commentaire
Partager sur d’autres sites

Veuillez vous connecter pour commenter

Vous pourrez laisser un commentaire après vous êtes connecté.



Connectez-vous maintenant
×
×
  • Créer...