php 如何在magento中获取页面标题?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/14950370/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get page title in magento?
提问by Rahul Singla
Any way to get the page title in magento...I Have a script live person..on this I need the current page title ..So can anybodey tell me how i get the current page title?
有什么方法可以在 magento 中获取页面标题......我有一个脚本活人..在这个我需要当前页面标题..那么任何人都可以告诉我如何获得当前页面标题?
回答by Mufaddal
use this code
使用此代码
$this->getLayout()->getBlock('head')->getTitle();
you can use this code in your phtml file
您可以在 phtml 文件中使用此代码
回答by Kevin Sadler
To get the title without the Prefix (site name):
要获得不带前缀(站点名称)的标题:
<?php echo str_replace(Mage::getStoreConfig('design/head/title_prefix'), '', $this->getLayout()->getBlock('head')->getTitle()); ?>

