2013-10-13 22 views
0

如何添加條件到我的新模塊(派生自mod_latest_news)的文章的ContentModel,以便它只提取今天創建的文章。我曾嘗試將以下內容添加到模塊的helper.php文件中:擴展Joomla的mod_latest_news,但獲取僅今天的文章

// Date must where created today 
$model->setState('a.created', date('Y-m-d')); 

但它似乎沒有幫助。難道我做錯了什麼?

+0

看看熱門的標籤模塊,它有一個基於時間的選項。 – Elin

回答

0

嘗試

$model->setState('filter.date_filtering', 'relative'); 
$model->setState('filter.relative_date', 1); 
+0

嗨,我使用你的代碼,它運行良好,直到我今天升級到joomla 3.2.2。我收到了錯誤消息。注意:未定義的變量:xxx/components/com_content/models/articles.php中的nowDate在線471 警告:爲xxx/components/com_content/models/articles.php上的foreach()提供的無效參數546 當在前臺作爲管理員登錄時。任何想法? 這是我的完整問題:http://stackoverflow.com/questions/21641365/joomla-3-2-2-issue-with-filter-date-filtering-relative謝謝! – webchun