需要进行哪些更改才能显示具有未来创建日期的帖子?
What changes would need to be made to show posts with future created dates?
我对此有点不知所措。我正在使用 AheadWorks 博客扩展将当前日历年的活动帖子添加到我的页面。该扩展还创建了这些帖子的提要,我将其提供给 Google 日历。正因为如此,我将事件的日期用作创建日期,因此它们可以正确地提供给 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'); ?>
只是更新 - 我想我在这里找到了我需要编辑的过滤器:
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 感谢您将它放在那里!
你很接近,只是改变;
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;
}
完美运行。
我对此有点不知所措。我正在使用 AheadWorks 博客扩展将当前日历年的活动帖子添加到我的页面。该扩展还创建了这些帖子的提要,我将其提供给 Google 日历。正因为如此,我将事件的日期用作创建日期,因此它们可以正确地提供给 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'); ?>
只是更新 - 我想我在这里找到了我需要编辑的过滤器:
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 感谢您将它放在那里!
你很接近,只是改变;
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;
}
完美运行。