artmajster
05-01-2010, 11:14
Witam serdecznie
mam ogromną prośbę
chciałbym przerobić moduł który wyświetla artykuły z wybranej kategorii bądź sekcji
ale
chciałby aby wyświetlał tylko artykuły z datą utworzenia przyszłą (nowszą niż dzisiaj)
niestety nie bardzo rozumiem o co chodzi w php ale wiem że trzeba to wykonać w helper.php
wiem że trzeba dodać warunek sprawdzania daty, ale nie bardzo wiem jak to wykonać
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'h elpers'.DS.'route.php');
class modLatestBySectionOrCategoryHelper
{
function getList(&$params)
{
global $mainframe;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$menus = &JSite::getMenu();
$currentMenu = $menus->getActive();
$menuOption=$currentMenu->query['option'];
if($menuOption=='com_content'){
$menuView=$currentMenu->query['view'];
if($menuView=='section'){
$secid=$currentMenu->query['id'];
$secCondition = ' AND a.sectionid='.$secid;
}elseif($menuView=='category'){
$catid=$currentMenu->query['id'];
$catCondition = ' AND a.catid='.$catid;
}
}elseif($menuOption=='com_sectionex'){
$menuView=$currentMenu->query['view'];
if($menuView=='category'){
$secid=$currentMenu->query['id'];
$secCondition = ' AND a.sectionid='.$secid;
}
}
$count = intval($params->get('count', 10));
$show_front = $params->get('show_front', 1);
$aid = $user->get('aid', 0);
$contentConfig = &JComponentHelper::getParams( 'com_content' );
$access = !$contentConfig->get('show_noauth');
$nullDate = $db->getNullDate();
jimport('joomla.utilities.date');
$date = new JDate();
$now = $date->toMySQL();
if ($catid) {
$ids = explode( ',', $catid );
JArrayHelper::toInteger( $ids );
$catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
}
if ($secid) {
$ids = explode( ',', $secid );
JArrayHelper::toInteger( $ids );
$secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
}
//Content Items only
$query = 'SELECT a.sectionid,a.title,a.access,' .
' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
' FROM #__content AS a' .
' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' .
' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
' WHERE ( a.state = 1 AND s.id > 0 )' .
' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )' .
' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'.
($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
($catid ? $catCondition : '').
($secid ? $secCondition : '').
($show_front == '0' ? ' AND f.content_id IS NULL' : '').
' AND s.published = 1' .
' AND cc.published = 1'.
' ORDER BY a.id DESC';
$db->setQuery($query, 0, $count);
$rows = $db->loadObjectList();
$i = 0;
$lists = array();
foreach ( $rows as $row )
{
if($row->access <= $aid)
{
$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
} else {
$lists[$i]->link = JRoute::_('index.php?option=com_user&view=login');
}
$lists[$i]->text = htmlspecialchars( $row->title );
$i++;
}
return $lists;
}
}
dziękuję z góry za wszelką pomoc
mam ogromną prośbę
chciałbym przerobić moduł który wyświetla artykuły z wybranej kategorii bądź sekcji
ale
chciałby aby wyświetlał tylko artykuły z datą utworzenia przyszłą (nowszą niż dzisiaj)
niestety nie bardzo rozumiem o co chodzi w php ale wiem że trzeba to wykonać w helper.php
wiem że trzeba dodać warunek sprawdzania daty, ale nie bardzo wiem jak to wykonać
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once (JPATH_SITE.DS.'components'.DS.'com_content'.DS.'h elpers'.DS.'route.php');
class modLatestBySectionOrCategoryHelper
{
function getList(&$params)
{
global $mainframe;
$db =& JFactory::getDBO();
$user =& JFactory::getUser();
$menus = &JSite::getMenu();
$currentMenu = $menus->getActive();
$menuOption=$currentMenu->query['option'];
if($menuOption=='com_content'){
$menuView=$currentMenu->query['view'];
if($menuView=='section'){
$secid=$currentMenu->query['id'];
$secCondition = ' AND a.sectionid='.$secid;
}elseif($menuView=='category'){
$catid=$currentMenu->query['id'];
$catCondition = ' AND a.catid='.$catid;
}
}elseif($menuOption=='com_sectionex'){
$menuView=$currentMenu->query['view'];
if($menuView=='category'){
$secid=$currentMenu->query['id'];
$secCondition = ' AND a.sectionid='.$secid;
}
}
$count = intval($params->get('count', 10));
$show_front = $params->get('show_front', 1);
$aid = $user->get('aid', 0);
$contentConfig = &JComponentHelper::getParams( 'com_content' );
$access = !$contentConfig->get('show_noauth');
$nullDate = $db->getNullDate();
jimport('joomla.utilities.date');
$date = new JDate();
$now = $date->toMySQL();
if ($catid) {
$ids = explode( ',', $catid );
JArrayHelper::toInteger( $ids );
$catCondition = ' AND (cc.id=' . implode( ' OR cc.id=', $ids ) . ')';
}
if ($secid) {
$ids = explode( ',', $secid );
JArrayHelper::toInteger( $ids );
$secCondition = ' AND (s.id=' . implode( ' OR s.id=', $ids ) . ')';
}
//Content Items only
$query = 'SELECT a.sectionid,a.title,a.access,' .
' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug,'.
' CASE WHEN CHAR_LENGTH(cc.alias) THEN CONCAT_WS(":", cc.id, cc.alias) ELSE cc.id END as catslug'.
' FROM #__content AS a' .
' LEFT JOIN #__content_frontpage AS f ON f.content_id = a.id' .
' INNER JOIN #__categories AS cc ON cc.id = a.catid' .
' INNER JOIN #__sections AS s ON s.id = a.sectionid' .
' WHERE ( a.state = 1 AND s.id > 0 )' .
' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )' .
' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'.
($access ? ' AND a.access <= ' .(int) $aid. ' AND cc.access <= ' .(int) $aid. ' AND s.access <= ' .(int) $aid : '').
($catid ? $catCondition : '').
($secid ? $secCondition : '').
($show_front == '0' ? ' AND f.content_id IS NULL' : '').
' AND s.published = 1' .
' AND cc.published = 1'.
' ORDER BY a.id DESC';
$db->setQuery($query, 0, $count);
$rows = $db->loadObjectList();
$i = 0;
$lists = array();
foreach ( $rows as $row )
{
if($row->access <= $aid)
{
$lists[$i]->link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug, $row->sectionid));
} else {
$lists[$i]->link = JRoute::_('index.php?option=com_user&view=login');
}
$lists[$i]->text = htmlspecialchars( $row->title );
$i++;
}
return $lists;
}
}
dziękuję z góry za wszelką pomoc