magento中消息(成功/错误)的路径?
我想更改magento中消息(成功/错误)的位置。我有密码 这是一个布局:magento中消息(成功/错误)的路径?,magento,Magento,我想更改magento中消息(成功/错误)的位置。我有密码 这是一个布局: <layout> <default> <reference name="after_body_start"> <block type="core/template" name="top.messages" template="core/messages/top.phtml" before="-" /> <
<layout>
<default>
<reference name="after_body_start">
<block type="core/template" name="top.messages" template="core/messages/top.phtml" before="-" />
</reference>
</default>
</layout>
这是一个模板文件:
<?php $_messageCollection = $this->getMessagesBlock()->getMessageCollection() ?>
<?php if ($_messageCollection->count()): ?>
<div>
<?php
echo $this->getMessagesBlock()->getGroupedHtml();
$_messageCollection->clear();
?>
</div>
<?php endif; ?>
这是用于将错误/成功消息更改到页面顶部的代码之一
我需要更改邮件的设计。哪个文件包含messages.phtml?我使用了这个路径文件app/design/frontend/your_-package/your_-theme/template/core/
但它不起作用。任何人都可以帮助改变这个设计
谢谢Prasoft
首先,据我所知,您需要更改错误消息的位置和设计
I.改变设计:你可以编辑Css来改变设计,但是如果你想改变HTML结构,也可以参考文件
magento/app/design/frontend/base/default/template/core/messages.phtml
当然,你需要改变你的主题
二,。要更改消息的位置,您需要引用该文件
magento/app/design/frontend/base/default/template/page/1column.phtml
参考代码
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
<?php echo $this->getChildHtml('global_notices') ?>
<div class="page">
<?php echo $this->getChildHtml('header') ?>
<div class="main-container col1-layout">
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
</div>
</div>
<?php echo $this->getChildHtml('footer') ?>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
>
当您谈论总是在全局\u消息部分下出现的错误消息时,要更改位置,请根据您的HTML结构重新定位此
行。Prasoft
首先,据我所知,您需要更改错误消息的位置和设计
I.改变设计:你可以编辑Css来改变设计,但是如果你想改变HTML结构,也可以参考文件
magento/app/design/frontend/base/default/template/core/messages.phtml
当然,你需要改变你的主题
二,。要更改消息的位置,您需要引用该文件
magento/app/design/frontend/base/default/template/page/1column.phtml
参考代码
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
<?php echo $this->getChildHtml('global_notices') ?>
<div class="page">
<?php echo $this->getChildHtml('header') ?>
<div class="main-container col1-layout">
<div class="main">
<?php echo $this->getChildHtml('breadcrumbs') ?>
<div class="col-main">
<?php echo $this->getChildHtml('global_messages') ?>
<?php echo $this->getChildHtml('content') ?>
</div>
</div>
</div>
<?php echo $this->getChildHtml('footer') ?>
<?php echo $this->getChildHtml('before_body_end') ?>
</div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
>
当您谈到总是在全局消息部分下出现的错误消息时,要更改位置,请根据HTML结构重新定位此
行。HTML不是在模板文件中生成的,而是在块中生成的-
因此,如果您想定制此功能,则:
重写Mage\u Core\u Block\u消息
,这样您就可以提供自己版本的getGroupedHtml()
自定义模板,使其使用getMessages()
而不是getGroupedHtml()
如果您使用方法2,那么您可以查看core/messages.phtml以获得灵感。您的模板可能类似于:
<?php
$types = array(
Mage_Core_Model_Message::ERROR,
Mage_Core_Model_Message::WARNING,
Mage_Core_Model_Message::NOTICE,
Mage_Core_Model_Message::SUCCESS
);
$html = '';
foreach ($types as $type) {
if ( $messages = $this->getMessagesBlock()->getMessages($type) ) {
if ( !$html ) {
$html .= '<ul class="messages">';
}
$html .= '<li class="' . $type . '-msg">';
$html .= '<ul>';
foreach ( $messages as $message ) {
$html.= '<li>';
$html.= $message->getText();
$html.= '</li>';
}
$html .= '</ul>';
$html .= '</li>';
}
}
if ( $html) {
$html .= '</ul>';
}
echo $html;
?>
<?php $_messageCollection = $this->getMessagesBlock()->getMessageCollection()->clear() ?>
不过不是模板的最好代码,所以你会考虑重构,并把一些逻辑移到一个块中,这将涉及到创建自己的模块。
< P> HTML不是在模板文件中生成的,而是在块-< /p>中生成的。
因此,如果您想定制此功能,则:
重写Mage\u Core\u Block\u消息
,这样您就可以提供自己版本的getGroupedHtml()
自定义模板,使其使用getMessages()
而不是getGroupedHtml()
如果您使用方法2,那么您可以查看core/messages.phtml以获得灵感。您的模板可能类似于:
<?php
$types = array(
Mage_Core_Model_Message::ERROR,
Mage_Core_Model_Message::WARNING,
Mage_Core_Model_Message::NOTICE,
Mage_Core_Model_Message::SUCCESS
);
$html = '';
foreach ($types as $type) {
if ( $messages = $this->getMessagesBlock()->getMessages($type) ) {
if ( !$html ) {
$html .= '<ul class="messages">';
}
$html .= '<li class="' . $type . '-msg">';
$html .= '<ul>';
foreach ( $messages as $message ) {
$html.= '<li>';
$html.= $message->getText();
$html.= '</li>';
}
$html .= '</ul>';
$html .= '</li>';
}
}
if ( $html) {
$html .= '</ul>';
}
echo $html;
?>
<?php $_messageCollection = $this->getMessagesBlock()->getMessageCollection()->clear() ?>
不过不是模板的最好代码,所以你需要考虑重构,并把一些逻辑移到一个块中,这将涉及创建自己的模块。