magento添加fancy页面 Creating fancy FAQ page

系统 1843 0

Introduction

Just keep reading this tutorial which will teach how to create a fancy FAQ with expandable/collapsible feature in an easier approach.

In short, creating a fancy FAQ section can be easily achieved in Magento by using CMS page & jQuery.


Steps

Go to Admin > CMS Pages > Add New Page and implement the following steps:


1. Add FAQ contents
Add the following content in the ‘Content’ > ‘Content’ section of CMS page:

    <div class="expand_wrapper">
    <h2 class="expand_heading"><a href="#">1. WordPress Theme Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">2. Magento E-commerce</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">3. Website Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
    <h2 class="expand_heading"><a href="#">4. PHP MySql Development</a></h2>
    <div class="toggle_container">
        <div class="box">
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
            <p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
        </div>
    </div>
</div>
  
 

2. Inject jQuery code
Add the following xml code in ‘Design’ > ‘Layout Update XML’ field of CMS page:

    <reference name="head">
    <block type="core/text" name="google.cdn.jquery">
        <action method="setText">
            <text><![CDATA[
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery(".toggle_container").slice(1).hide();//expands first FAQ content
        jQuery(".expand_heading:first").addClass("active");//add active class to first FAQ title
        jQuery("h2.expand_heading").click(function(event){
            event.preventDefault()
            jQuery(this).toggleClass("active");
            jQuery(this).next(".toggle_container").slideToggle("slow");
        });
    });
</script>
 
            ]]></text>
        </action>
    </block>
</reference>
  
 

3. You’re done
Go to the frontend and open the FAQ page, you will see as:

 

magento添加fancy页面 Creating fancy FAQ page in Magento – an easier approach

FAQ Page With Expand/Collapse

 

 

来源: http://www.blog.magepsycho.com/creating-fancy-faq-page-in-magento-an-easier-approach/

 

 

magento添加fancy页面 Creating fancy FAQ page in Magento – an easier approach


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论