代码之家  ›  专栏  ›  技术社区  ›  WorkingMan8798

需要进行哪些更改才能显示具有未来创建日期的帖子?

  •  0
  • WorkingMan8798  · 技术社区  · 10 年前

    我在这件事上有点不知所措。我正在使用AheadWorks博客扩展将当前日历年的事件帖子添加到我的页面。该扩展还创建了这些帖子的提要,我正在将其馈送到GoogleCalendar。正因为如此,我使用事件的日期作为创建的日期,因此它们可以正确地输入到Google日历中。然而,我不知道如何让Magento显示所有帖子;它只显示创建日期为当天或更早的日期。我理解这是默认设置;我怎样才能绕过它,让所有的帖子都显示出来,而不管created_time如何?

    我看到了一些关于更改存储时间的建议,其中一些建议提到编辑created.php文件,但我真的不确定从何开始?

    有人能告诉我需要做什么吗?

    这里是app/code/community/AW/Blog/Block/Blog.php:

    <?php
    /**
     * aheadWorks Co.
     *
     * NOTICE OF LICENSE
     *
     * This source file is subject to the EULA
     * that is bundled with this package in the file LICENSE.txt.
     * It is also available through the world-wide-web at this URL:
     * http://ecommerce.aheadworks.com/AW-LICENSE.txt
     *
     * =================================================================
     *                 MAGENTO EDITION USAGE NOTICE
     * =================================================================
     * This software is designed to work with Magento community edition and
     * its use on an edition other than specified is prohibited. aheadWorks does     not
     * provide extension support in case of incorrect edition use.
     * =================================================================
     *
     * @category   AW
     * @package    AW_Blog
     * @version    1.3.4
     * @copyright  Copyright (c) 2010-2012 aheadWorks Co.   (http://www.aheadworks.com)
     * @license    http://ecommerce.aheadworks.com/AW-LICENSE.txt
     */
    
    
    class AW_Blog_Block_Blog extends AW_Blog_Block_Abstract
    {
        public function getPosts()
        {
            $collection = parent::_prepareCollection();
            $tag = $this->getRequest()->getParam('tag');
            if ($tag) {
                $collection->addTagFilter(urldecode($tag));
            }
            parent::_processCollection($collection);
            return $collection;
        }
    
        protected function _prepareLayout()
        {
            if ($this->isBlogPage() && ($breadcrumbs = $this->getCrumbs())) {
                parent::_prepareMetaData(self::$_helper);
                $tag = $this->getRequest()->getParam('tag', false);
                if ($tag) {
                    $tag = urldecode($tag);
                    $breadcrumbs->addCrumb(
                        'blog',
                        array(
                            'label' => self::$_helper->getTitle(),
                            'title' => $this->__('Return to ' . self::$_helper-    >getTitle()),
                            'link'  => $this->getBlogUrl(),
                        )
                    );
                    $breadcrumbs->addCrumb(
                        'blog_tag',
                        array(
                            'label' => $this->__('Tagged with "%s"',     self::$_helper->convertSlashes($tag)),
                            'title' => $this->__('Tagged with "%s"', $tag),
                        )
                    );
                } else {
                    $breadcrumbs->addCrumb('blog', array('label' =>     self::$_helper->getTitle()));
                }
            }
        }
    }
    

    这里是app/design/frontend/[主题]/[主题]/template/aw_blog/blog.phtml:

    <?php
    /**
     * aheadWorks Co.
     *
     * NOTICE OF LICENSE
     *
     * This source file is subject to the EULA
     * that is bundled with this package in the file LICENSE.txt.
     * It is also available through the world-wide-web at this URL:
     * http://ecommerce.aheadworks.com/AW-LICENSE.txt
     *
     * =================================================================
     *                 MAGENTO EDITION USAGE NOTICE
     * =================================================================
     * This software is designed to work with Magento community edition and
     * its use on an edition other than specified is prohibited. aheadWorks does  not
     * provide extension support in case of incorrect edition use.
     * =================================================================
     *
     * @category   AW
     * @package    AW_Blog
     * @version    1.3.4
     * @copyright  Copyright (c) 2010-2012 aheadWorks Co.   (http://www.aheadworks.com)
     * @license    http://ecommerce.aheadworks.com/AW-LICENSE.txt
     */
    ?><?php $posts = $this->getPosts(); ?>
    <div id="messages_product_view">
        <?php Mage::app()->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('customer/session')->getMessages(true)); ?>
        <?php echo Mage::app()->getLayout()->getMessagesBlock()->getGroupedHtml(); ?>
    </div>
    
    <?php echo $this->getChildHtml('aw_blog_comments_toolbar'); ?>
    
    <?php foreach ($posts as $post): ?>
    
        <div class="postWrapper">
            <div class="postTitle">
                <h2><a href="<?php echo $post->getAddress(); ?>" ><?php echo $post->getTitle(); ?></a></h2>
                <h3><?php echo $post->getCreatedTime(); ?></h3>
            </div>
            <div class="postContent">
                <?php echo $post->getPostContent(); ?>
            </div>
    
            <?php echo $this->getBookmarkHtml($post) ?>
            <div class="tags"><?php echo $this->getTagsHtml($post) ?></div>
            <div class="postDetails">
                <?php if ($this->getCommentsEnabled()): ?>
                    <?php echo $post->getCommentCount(); ?> <a href="<?php echo $post->getAddress(); ?>#commentBox" > <?php echo Mage::helper('blog')->__('Comments'); ?></a> |
                <?php endif; ?>
                <?php $postCats = $post->getCats(); ?>
                <?php if (!empty($postCats)): ?>
                    <?php echo Mage::helper('blog')->__('Posted in'); ?>
                    <?php foreach ($postCats as $data): ?>
                        <a href="<?php echo $data['url']; ?>"><?php echo $data['title']; ?></a>
                    <?php endforeach; ?>
                <?php else: ?>
                    <?php echo Mage::helper('blog')->__('Posted'); ?>
                <?php endif; ?><?php echo $this->__("By"); ?> <?php echo $post->getUser(); ?></div>
        </div>
    
    <?php endforeach; ?>
    <?php echo $this->getChildHtml('aw_blog_comments_toolbar'); ?>
    
    2 回复  |  直到 10 年前
        1
  •  0
  •   mg33dev    10 年前

    你很接近,只是改变;

    public function addPresentFilter()
        {
            $this->getSelect()->where('main_table.created_time<=?', now());
            return $this;
        }
    

    public function addPresentFilter()
        {
            $this->getSelect()->where('main_table.update_time<=?', now());
            return $this;
        }
    

    工作完美。

        2
  •  0
  •   WorkingMan8798    10 年前

    只是一个更新-我想我在这里找到了需要编辑的过滤器:

    app/code/community/AW/Blog/Model/Mysg14/Blog/Collection.php

    public function addPresentFilter()
    {
        $this->getSelect()->where('main_table.created_time<=?', now());
        return $this;
    }
    

    我改为:

    public function addPresentFilter()
    {
        $this->getSelect()->where('main_table.created_time>=?', now());
        return $this;
    }
    

    我试着完全解释一下,但。。。白屏;所以我仍在修改以显示所有内容,jhgraphics感谢您的帮助!