討論區: osCommerce カスタマイズ (Thread #5614)

タイトル、メタタグ、キーワードを個別に設定する (2004-07-22 13:15 by 匿名 #10294)

以下をファイル名 title_mata.php としてください
------------------------------------------

<?php
/*****
title_mata.php
下記を参考にしました 著作権は下記のお二人にあります。
http://lists.sourceforge.jp/mailman/archives/tep-j-general/2004-July/002210.html
http://lists.sourceforge.jp/mailman/archives/tep-j-general/2003-August/002806.html

/catalog/includesにtitle_mata.phpを配置し、catalog/product_info.phpヘッダ内の

<title><?php echo TITLE; ?></title>
を 下記と入れ替える

<?php
require(DIR_WS_INCLUDES . 'title_mata.php');
?>
title、metaタグのkeywordとdescriptionの行 を生成します。

******/

$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, m.manufacturers_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'" . " and p.manufacturers_id = m.manufacturers_id and pd.language_id ='" . (int)$languages_id . "'");

//クエリを投げる
$the_product_info = tep_db_fetch_array($the_product_info_query);

//タイトルを作成
$the_title= $the_product_info['products_name'];
echo ' <title>' . TITLE .' - ' .$the_title . '</title>' . "\n";

//キーワードタグを作成
echo "<meta name=\"keyword\" content=\"" . $the_product_info['manufacturers_name'] ; //先ずメーカー名をキーワードに入れる

//取得した商品名を半角スペース毎に分解して配列に収納
$pieces = explode(" ", $the_product_info['products_name']);

//分解した商品名部品をカンマ区切りで出力
//あまりにも「商品名の空白区切り」で出来る部品が多い場合は、行が冗長になったりスパム扱いされるのを避けるためキーワード個数を制限する必要があるかもしれない

$i = 0;

do {
echo "," . $pieces[$i];
$i++;

} while($pieces[$i] != ""); //部品が無くなるまでループ

echo "\">\n";

//説明タグを作成
echo "<meta name=\"description\" content=\"";

//「説明は100字以内くらい」との事なので、とりあえず150バイトにしてます
//説明内にタグや改行が含まれてると都合悪いので、除去

$description = mb_strcut(ereg_replace("\n|\r|\r\n"," ",strip_tags($the_product_info['products_description'])),0,150);

echo $description;

echo "\">\n";

?>

回覆 #10294×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入

RE: タイトル、メタタグ、キーワードを個別に設定する (2004-07-22 13:18 by 匿名 #10295)

title_meta.php にするつもりが

title_mata.php に・・(ToT)

実害はないです。
回覆: #10294

回覆 #10295×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入

RE: タイトル、メタタグ、キーワードを個別に設定する(関連) (2008-02-03 11:22 by 匿名 #34852)

初歩的な質問で恐縮ですが、

トップページのタイトル(当初"osCommerce")を変更したのですが、対処法のご指導をお願いします。
回覆: #10295

回覆 #34852×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入

RE: タイトル、メタタグ、キーワードを個別に設定する(関連) (2008-02-03 17:48 by 匿名 #34856)

自己レスです。

catalog/includes/laguages/japanese.phpに下記を追加
// page title
define ('TITLE' , 'タイトル名');
にて表示させることができました。
回覆: #34852

回覆 #34856×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入

SEO (2004-09-03 10:51 by 匿名 #10868)

これは、SEO対策になりますね。 (^人^)感謝♪
回覆: #10294

回覆 #10868×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入

今は (2004-10-05 15:25 by 匿名 #11393)

>あまりにも「商品名の空白区切り」で出来る部品が
>多い場合は、行が冗長になったりスパム扱いされる
>のを避けるためキーワード個数を制限する必要があ
>るかもしれない

ということなんで、

do {
echo "," . $pieces[$i];
$i++;

} while($pieces[$i] != "" | $i > 10); //部品が無くなるか10単語までループ

↑こう直してます。採用単語数は、まぁ適当に。
回覆: #10294

回覆 #11393×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入

RE: (2006-03-27 11:48 by 匿名 #20881)

ありがとうございます
回覆: #10294

回覆 #20881×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) 登入