문제

I want text in <h1> tag to match page title, but without store prefix.

I'm getting page title like so:

<h1>
    <?php echo $this->getLayout()->getBlock('head')->getTitle(); ?></h1>

How can I get page title without store prefix, or how can I retrieve store prefix option?

Thank you!

도움이 되었습니까?

해결책

The quick and dirty way to do it.

To cut prefix:

<?php 
$prefix = Mage::getStoreConfig('design/head/title_prefix');
$title = $this->getLayout()->getBlock('head')->getTitle();
$processedTitle = trim(substr($title, strlen($prefix)));
?>
<h1><?php echo $processedTitle;?></h1>

To cut suffix:

<?php 
$suffix = Mage::getStoreConfig('design/head/title_suffix');
$title = $this->getLayout()->getBlock('head')->getTitle();
$processedTitle = substr($title, 0, strlen($suffix) * -1);
?>
<h1><?php echo $processedTitle;?></h1>

다른 팁

Just access the _data-Array directly:

$this->getLayout()->getBlock('head')->getData('title');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top