magento 模板--左边栏

来源:互联网 发布:淘宝收藏按钮怎么设置 编辑:程序博客网 时间:2024/04/28 20:00
边栏:左边栏,右边栏page.xml 定义:--------------------------------   <block type="core/text_list" name="left" as="left" translate="label">                <label>Left Column</label>            </block>.................................................. <block type="core/text_list" name="content" as="content" translate="label">                <label>Main Content Area</label>            </block>....................................................................................................     <block type="core/text_list" name="right" as="right" translate="label">                <label>Right Column</label>            </block>=====================================================主页样式:1column.phtml,2columns-right.phtml,2columns-left.phtml,3columns.phtml,empty.phtml,popup.phtml,print.phtml 里定义------------------------------------------<div class="main-container col3-layout">            <div class="main">                <?php echo $this->getChildHtml('breadcrumbs') ?>                <div class="col-wrapper">                    <div class="col-main">                        <?php echo $this->getChildHtml('global_messages') ?>                        <?php echo $this->getChildHtml('content') ?>                    </div>                    <div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>                </div>                <div class="col-right sidebar"><?php echo $this->getChildHtml('right') ?></div>            </div>        </div>-------------------------------------------------  在catalog.xml 里重新定义left,right左边栏的banner---------------------------------------------------------- <reference name="left">            <block type="core/template" name="left.permanent.callout"template="callouts/left_col.phtml">                <action method="setImgSrc"><src>images/media/col_left_callout.jpg</src></action>                <action method="setImgAlt" translate="alt" module="catalog"><alt>Our customer service is available 24/7. Call us at (555) 555-0123.</alt></action>                <action method="setLinkUrl"><url>checkout/cart</url></action>            </block>        </reference>====================================================left_col.phtml 的内容:----------------------------------------------<div class="block block-banner">    <div class="block-content">        <?php if(strtolower(substr($this->getLinkUrl(),0,4))==='http'): ?>            <a href="<?php echo $this->getLinkUrl() ?>" title="<?php echo $this->__($this->getImgAlt()) ?>">        <?php elseif($this->getLinkUrl()): ?>            <a href="<?php echo $this->getUrl($this->getLinkUrl()) ?>" title="<?php echo $this->__($this->getImgAlt()) ?>">        <?php endif; ?>            <img src="<?php echo $this->getSkinUrl($this->getImgSrc()) ?>"<?php if(!$this->getLinkUrl()): ?> title="<?php echo $this->__($this->getImgAlt()) ?>"<?php endif; ?> alt="<?php echo $this->__($this->getImgAlt()) ?>" />        <?php if($this->getLinkUrl()): ?>        </a>        <?php endif ?>    </div></div>=============================================================getLinkUrl() 获得<action method="setLinkUrl"><url>的值,如果值是完整的URL,输出不完整, getUrl() 获得网站的地址,和<action method="setLinkUrl"><url>的值连在一起。getImgAlt() 获得<action method="setImgAlt" translate="alt" module="catalog"><alt>的值getSkinUrl 获得模板skin的完整路径getImgSrc() 获得<action method="setImgSrc"><src> 的值左边栏的tag在tag.xml里重新定义左边栏:-----------------------------------------------------    <default>        <!-- Mage_Tag -->        <reference name="left">            <block type="tag/popular" name="tags_popular" template="tag/popular.phtml"/>        </reference>    </default>=====================================================模板tag/popular.phtml---------------------------------<div class="block block-tags">    <div class="block-title">        <strong><span><?php echo $this->__('Popular Tags'); ?></span></strong>    </div>    <div class="block-content">        <ul class="tags-list">            <?php foreach ($this->getTags() as $_tag): ?>                <li><a href="<?php echo $_tag->getTaggedProductsUrl() ?>" style="font-size:<?php echo $_tag->getRatio()*70+75 ?>%;"><?php echo $this->htmlEscape($_tag->getName()) ?></a></li>            <?php endforeach; ?>        </ul>        <div class="actions">            <a href="<?php echo $this->getUrl('tag/list') ?>"><?php echo $this->__('View All Tags') ?></a>        </div>    </div></div>=================================================getTags()  猜想是从数据库里调用。 左边栏的newsletternewsletter.xml 重新定义left------------------------------------------------------    <default>        <!-- Mage_Newsletter -->        <reference name="left">            <block type="newsletter/subscribe" name="left.newsletter" template="newsletter/subscribe.phtml"/>        </reference>    </default>====================================================

0 0
原创粉丝点击