カテゴリを取得したいとMagentoの中でページタイトルに入れた:私はカテゴリを取得し、title.Myに入れたい私はこれは私が(head.phtmlに)変更するコードである
<meta http-equiv="Content-Type" content="<?php echo $this->getContentType() ?>" />
<title><?php echo $this->getTitle() ?></title>
<meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />
<meta name="keywords" content="<?php echo htmlspecialchars($this->getKeywords()) ?>" />
<meta name="robots" content="<?php echo htmlspecialchars($this->getRobots()) ?>" />
<link rel="shortcut icon" href="<?php echo $this->getFaviconFile(); ?>" type="image/x-icon" />
<?php echo $this->getCssJsHtml() ?>
<?php echo $this->getChildHtml() ?>
<?php echo $this->getIncludes() ?>
コードは
?php
$currentCategory = Mage::registry("current_category");
?>
<?php $_title = $currentCategory->getName(); ?>
<meta http-equiv="Content-Type" content="<?php echo $this->getContentType() ?>" />
<title><?php echo $_title ?></title>
<meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />
<meta name="keywords" content="<?php echo htmlspecialchars($this->getKeywords()) ?>" />
<meta name="robots" content="<?php echo htmlspecialchars($this->getRobots()) ?>" />
link rel="shortcut icon" href="<?php echo $this->getFaviconFile(); ?>" type="image/x-icon" />
<?php echo $this->getCssJsHtml() ?>
<?php echo $this->getChildHtml() ?>
<?php echo $this->getIncludes() ?>
カテゴリ項目にあるときはうまく動作しますが、ホームページではそれ以上開いていません。 私は$ _titleが空であるとかそういうものだと思います。 if文を実装しようとしましたが、同じ問題です。
私の英語のために残念です。
私の最初のページの仕事はOKですが、新しい問題があります。私は後で詳しく説明します。 – RobyBoy
オハイオ州私はあなたを手伝ってくれます、あなたはこの答えを受け入れることができますか?ありがとう –
今問題は:私のタイトル私は "最高品質$ _title"になりたいが、カテゴリ "病気"があるとき、それは奇妙な "最高品質の病気"と聞こえる。別の変数とタイトルを "$ _newTitleの商品"に挿入する場合は、最初にifを作成しているのだろうかと思います。 – RobyBoy