不确定我是否理解你的问题。
想要为商店用品站点添加新路径(例如 /brands)。
如果您想使用自己的页面添加新路径,您应该创建新控制器:
public function install() {
$this->registerController('Frontend', 'Example');
}
控制器应放置在OurPluginRoot/Controllers/Frontend/Example.php
class Shopware_Controllers_Frontend_Example extends Enlight_Controller_Action
{
public function indexAction()
{
$this->view->assign('variable', 'value');
}
}
然后我们为我们的新控制器添加索引操作模板OurPluginRoot/View/example/index.tpl
{extends file='frontend/index/index.tpl'}
{block name="frontend_index_content"}
<div class="container">
My own controller view
</div>
{/block}
您可以通过后端设置现有控制器的路径。
如果您需要扩展现有模板,您需要为此编写非常简单的插件。
class Shopware_Plugins_Frontend_ExtendQuickCart_Bootstrap extends Shopware_Components_Plugin_Bootstrap {
/**
* Returns the version of plugin as string.
*
* @return string
*/
public function getVersion() {
return '0.0.1';
}
/**
* Returns the plugin name for backend
*
* @return string
*/
public function getLabel() {
return 'Extend Quick Cart View';
}
/**
* Standard plugin install method to register all required components.
* @return array
*/
public function install() {
$this->subscribeEvent();
}
/**
* @return Shopware_Plugins_Frontend_ExtendQuickCart_Bootstrap
*/
private function subscribeEvents(){
//Frontend_Checkout -> Frontend/Backend, Checkout mean controller checkout
$this->subscribeEvent(
'Enlight_Controller_Action_PostDispatch_Frontend_Checkout', 'onPostDispatchCheckout'
);
return $this;
}
/**
* @param Enlight_Controller_ActionEventArgs $arguments
*/
public function onPostDispatchCheckout(Enlight_Controller_ActionEventArgs $arguments){
/**@var $controller Shopware_Controllers_Frontend_Checkout */
$controller = $arguments->getSubject();
$request = $controller->Request();
$response = $controller->Response();
$action = $request->getActionName();
$view = $controller->View();
// Extend only ajaxCart Action, all other actions - don't do anything
if ( $action !== 'ajaxCart' || !$request->isDispatched()
|| $response->isException() || !$view->hasTemplate()
) {
return;
}
$view->addTemplateDir($this->Path() . 'Views/');
}
}
然后创建模板OurPluginRoot/View/checkout/ajax_cart.tpl
{extends file='parent:frontend/checkout/ajax_cart.tpl'}
{block name='frontend_checkout_ajax_cart_prices_container_inner'}
<div class="prices--articles">
<span class="prices--articles-text">{s name="AjaxCartTotalAmount"}{/s}</span>
<span class="prices--articles-amount">{$sBasket.Amount|currency}</span>
</div>
<div class="prices--articles">
<span class="prices--articles-text">{s name="AjaxSomething"}Something{/s}</span>
<span class="prices--articles-amount">{$sBasket.Amount}</span>
</div>
<div class="prices--articles">
<span class="prices--articles-text">{s name="AjaxSomething1"}Something ssecond{/s}</span>
<span class="prices--articles-amount">@@@@@@@@@@@@@@@@@</span>
</div>
{/block}
在那里你可以找到带有测试插件的存档,你可以学习,希望这对你有用。