doudi2833 2014-07-21 23:16
浏览 73

如何将jquery readmore函数(展开/折叠)添加到magento CMS页面

I need a read more button link in my Magento CMS pages.

I got some long cms texts. I need a Read More link to collapse them.

The Read More link has to be always after the first paragraph or ofter 250 character or any other limitation. But it is better when I can place the link myself in the magento backend by adding some kind of shortcode. like [readmore] or something. Doesn't matter what.

this is an example what im trying to do. http://www.feestding.nl/themakleding/beste-thema-s/halloween-kostuums/

example of the feature http://jedfoster.com/Readmore.js/

how can i do it?

  • 写回答

2条回答 默认 最新

  • dongmibeng5885 2014-07-22 02:35
    关注

    Download readmore.js and add it into your page.xml of your template. Make sure your path is correct and you have proper jquery already in use, if not then link the jquery file as well.

        <action method="addJs"><script>readmore.js</script></action>
    

    In backend, always put your contents inside a div with a specific class like below to make the read more link appear

        <div class="readmore">.......</div>
    

    Depending on where you want the read more to display either in cms pages, category pages or product pages, you have to add the following readmore script accordingly in those pages. You can also add the script in your CMS pages from the editor in backend.

        <script type="text/javascript">
             jQuery('.readmore').readmore({maxHeight:40});  
        </script>
    

    There are couple of options that we can use with readmore.js, follow the documentation here

    Beware of jQuery conflicts, you might need to use noConflict() to make this readmore script work. Hope you can make this work.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度