Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento中购物车页面标题的更改_Php_Magento_Magento 1.5 - Fatal编程技术网

Php Magento中购物车页面标题的更改

Php Magento中购物车页面标题的更改,php,magento,magento-1.5,Php,Magento,Magento 1.5,我需要更改购物车页面标题。但是我找不到它。我应该在哪里换。因此,感谢您的帮助 谢谢下面是一个如何覆盖标题的简短示例 您可以更改变量并覆盖指定的layout.xml文件中的标题。该页面的标题实际上是在xml中设置的。您应该在app/design/frontend/packagename/themename/layout/目录中打开checkout.xml文件,并将此代码放在xml中的节点内: <reference name="head"> <action method

我需要更改购物车页面标题。但是我找不到它。我应该在哪里换。因此,感谢您的帮助


谢谢

下面是一个如何覆盖标题的简短示例


您可以更改变量并覆盖指定的layout.xml文件中的标题。

该页面的标题实际上是在xml中设置的。您应该在
app/design/frontend/packagename/themename/layout/
目录中打开checkout.xml文件,并将此代码放在xml中的节点内:

<reference name="head">
    <action method="setTitle"><title>My New Checkout Title</title></action>
</reference>


.

更改XML将无效,因为标题由控制器在app/code/core/Mage/Checkout/controllers/CartController.php中设置

$this
->loadLayout()
->_initLayoutMessages('checkout/session')
->_initLayoutMessages('catalog/session')
->getLayout()->getBlock('head')->setTitle($this->__('Shopping Cart'));
修改核心文件从来都不是一个好主意,重写控制器可能会很乏味。因此,最正确、最快捷的更改位置是在翻译文件中,位于app/locale/your_LANGUAGE/Mage_Checkout.csv。如果您的相关目录中没有此文件,您可以创建它并添加以下行:

"Shopping Cart","NEW TITLE HERE"
如果您确实有该文件,则只需编辑该行,确保您的新标题紧跟原始标题和逗号,并用双引号括起来。

尝试以下操作:

<reference name="head">
     <action method="setTitle"><title>My New Checkout Title</title></action>
</reference>

我的新收银台名称

正确的方法是在签出控制器上进行覆盖,这非常简单。 第一: 添加一个包含两个子目录的新模块:控制器等。 Mynamespace/签出/控制器 Mynamespace/Checkout/etc

然后,在etc目录中添加文件:CartController.php,其中包含以下内容:

require_once 'Mage/Checkout/controllers/CartController.php';

class Mynamespace_Checkout_CartController extends Mage_Checkout_CartController
{

public function indexAction()
{
    $cart = $this->_getCart();
    if ($cart->getQuote()->getItemsCount()) {
        $cart->init();
        $cart->save();

        if (!$this->_getQuote()->validateMinimumAmount()) {
            $minimumAmount = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())
                ->toCurrency(Mage::getStoreConfig('sales/minimum_order/amount'));

            $warning = Mage::getStoreConfig('sales/minimum_order/description')
                ? Mage::getStoreConfig('sales/minimum_order/description')
                : Mage::helper('checkout')->__('Minimum order amount is %s', $minimumAmount);

            $cart->getCheckoutSession()->addNotice($warning);
        }
    }

    // Compose array of messages to add
    $messages = array();
    foreach ($cart->getQuote()->getMessages() as $message) {
        if ($message) {
            // Escape HTML entities in quote message to prevent XSS
            $message->setCode(Mage::helper('core')->escapeHtml($message->getCode()));
            $messages[] = $message;
        }
    }
    $cart->getCheckoutSession()->addUniqueMessages($messages);

    /**
     * if customer enteres shopping cart we should mark quote
     * as modified bc he can has checkout page in another window.
     */
    $this->_getSession()->setCartWasUpdated(true);

    Varien_Profiler::start(__METHOD__ . 'cart_display');
    $this
        ->loadLayout()
        ->_initLayoutMessages('checkout/session')
        ->_initLayoutMessages('catalog/session')
        ->getLayout()->getBlock('head')->setTitle($this->__('Here it go the new title!!!!'));
    $this->renderLayout();
    Varien_Profiler::stop(__METHOD__ . 'cart_display');
    }
} 
然后是config.xml文件:

<config>
    <modules>
    <Mynamespace_Checkout>
        <version>0.1.0</version>
    </Mynamespace_Checkout>
</modules>
<frontend>
    <routers>
        <checkout>
            <args>
                <modules>
                    <mynamespace_sales before="Mage_Checkout">Mynamespace_Checkout</mynamespace_sales>
                </modules>
            </args>
        </checkout>
    </routers>
</frontend>

0.1.0
MyU签出

最后是模块激活器:app/etc/modules/Mynamespace_Checkout.xml

<config>
    <modules>
        <Mynamespace_Checkout>
            <active>true</active>
            <codePool>local</codePool>
        </Mynamespace_Checkout>
    </modules>
</config>

符合事实的
地方的
这在Magento Enterprise 1.13中进行了测试


问候语

我在checkout.xml中添加了这个,但不起作用。。任何建议。谢谢购物袋所有的步骤你都做了吗?嗯。。。理论上,app/locale/locale\u SETTING/Mage\u Checkout.csv也是一个核心文件。。。仅当您进行本地覆盖并添加自己的翻译文件(app/locale/locale\u SETTING/Namespace\u Module.csv)时,才会将其视为非核心文件;)
<config>
    <modules>
        <Mynamespace_Checkout>
            <active>true</active>
            <codePool>local</codePool>
        </Mynamespace_Checkout>
    </modules>
</config>