0

以下は、別の開発者がすぐに作成した Joomla 1.5 拡張機能の 1 ページです。これは、最終的にコア Joomla 関連記事のように機能しますが、もう少しカスタマイズされています。コードはあまりきれいではありませんが、機能します。現在閲覧中のページで同じタグが付けられている記事のうち、最新の5件の記事のタイトルと日付を表示します。唯一の問題は、2013 年の記事が 2 つしかないため、2013 年と 2012 年の記事が表示されることです。したがって、最終的には、今年の 5 つの関連アイテムのみが表示されるはずです。そのため、2013 年 (現在) で、2013 年の記事が 4 つしかない場合、それらの 4 つだけを表示する必要があります。

行上: for($y=2001; $y <= $intYear; $y++)2001 を 2013 に変更しようとしましたが、フロント エンドは何も変更しませんでした。2014年に変更しようとしましたが、何も変更されませんでした。

私が考えていたもう1つのオプションは、行に$objDb->setQuery("SELECT sectionid, catid, titleありました.WHERE created = '$ currentYear'のようなものを言う方法があれば。

繰り返しになりますが、コードはきれいではなく、パフォーマンスがそれほど優れていないことを想像してください。ただし、後でモジュール全体をより良いソリューションに置き換えることができるまで、この問題の迅速な修正を探しています。どんな助けでも大歓迎です!

<?php
// Include the syndicate functions only once
//require_once (dirname(__FILE__).DS.'helper.php');
//
//$list = modRelatedItemsHelper::getList($params);
//
//if (!count($list)) {
//  return;
//}
//
//$showDate = $params->get('showDate', 0);
//
//require(JModuleHelper::getLayoutPath('mod_related_items'));


// no direct access

defined('_JEXEC') or die('Restricted access');

// Include the syndicate functions only once
include_once( dirname(__FILE__).DS.'helper.php' );

if( !defined('NL') )
 { define('NL', "\n"); }

$prmRptShowFilter=$params->get('rpt_show_filter');
$prmRptSection=$params->get('rpt_section');
$prmRptCategory=$params->get('rpt_category');
$prmRptDateFormat=$params->get('rpt_date_format');


$arrMonths=array();
$arrMonths[1]='January';
$arrMonths[2]='February';
$arrMonths[3]='March';
$arrMonths[4]='April';
$arrMonths[5]='May';
$arrMonths[6]='June';
$arrMonths[7]='July';
$arrMonths[8]='August';
$arrMonths[9]='September';
$arrMonths[10]='October';
$arrMonths[11]='November';
$arrMonths[12]='December';

$arrYears=array();
$intYear=date(Y);
for($y=2001; $y <= $intYear; $y++)
 { $arrYears[]=$y; }

$varArticleId=JRequest::getVar('id');
$objDb=&JFactory::getDBO();

//--- Database Script ---//
$objDb->setQuery("SELECT sectionid, catid, title FROM #__content WHERE id='$varArticleId' LIMIT 1");
$rows=$objDb->loadObjectList();
$section_id=$rows[0]->sectionid;
$cat_id=$rows[0]->catid;
//--- Database Script ---//

$arrList=modGtSidebarCustomHelper::getList($params);

?>
<style type="text/css">
#idForm1 {
 float: right;
}
#idForm1 ul {
 margin: 0;
 padding: 0;
 list-style: none;
 clear: both;
}
#idForm1 li {
 float: left;
 margin: 0 1px 0 0;
 padding: 0;
}
#idGtReportDisplayB {
    text-align:left;
    margin:3px 5px;
}
#idGtReportDisplayB a:hover {
 text-decoration: underline;
    font-weight: normal;    
}

#idGtReportDisplayB span.zoom-link {
 display: none; 
}
#idGtReportDisplayB dl, 
#idGtReportDisplayB dl dt, 
#idGtReportDisplayB dl dd {
    padding: 0px 5px 0px 5px;
    margin: 0;
}

#idGtReportDisplayB dd {
    color: #680e0e;
}

#idGtReportDisplayB dl {
  width: 284px;
    padding-bottom: 15px;   
}

#idNoRelatedLatestNews {
 display: none;
}

</style>
<div id="idGtReportDisplayB">
<?php
 $strDisplay='';
 $prmRptDateFormat='n/j/Y';

 if( !empty($arrList) )
  {
   $strDisplay.='<h2>Recent News</h2>'. NL;

   $numSize=sizeof($arrList);
   for($x=0; ($x < $numSize) && ($x <= 5); $x++)
    {
     $tmpDtm=strtotime($arrList[$x]->created);

     $strDisplay.='<dl>'. NL;
     $strDisplay.=' <dt><a href="'. $arrList[$x]->route .'">'. $arrList[$x]->title .'</a></dt>'. NL;
     $strDisplay.=' <dd>'. date($prmRptDateFormat, $tmpDtm) .'</dd>'. NL;
     $strDisplay.='</dl>'. NL;
    }

   echo($strDisplay);
  }
 else
  {
#   include( dirname(__FILE__).DS.'..'.DS.'mod_latestnews'.DS.'mod_latestnews.php' );
?>
<style type="text/css">
#idNoRelatedLatestNews {
  display: block;
}
</style>
<?
  }
?>
    </ul>
</div>
4

2 に答える 2