OK versuchts mal damit:
1.) Das muss in die config.inc.php:
Code: Select all
// Number record per page
$template_default["record_per_page"] = 4;
Hier wird eingestellt, wieviele Artikel pro Seite angezeigt werden sollen.
2.) in der config.inc.php muss nun noch folgendes aktiviert sein:
Code: Select all
$phpwcms["allow_ext_init"] = 1; //allow including of custom external scripts at frontend initialization
3.) Erstellt eine Datei "listpages" im Ordner "phpwcms_template/inc_script/frontend_init" mit folgendem Inhalt:
Code: Select all
<?
function pager( $pg, $pglen, $cnt, $q ) {
/*
Input :
$pg: Current page
$pglen: Number of items on a page
$cnt: Total number of items
$q: Query string (optional)
Output:
List pages
*/
$pages = ceil($cnt/$pglen);
if ( $pages == 1 ) return;
$lst_pgs = "<div class=\"clear\"><p></p></div><div align='center'>";
if ( $pg > 1 )
$lst_pgs .= "<a style='text-decoration: none' href='index.php?".$q."&pg=".($pg-1)."'><<</a> ";
// echo
for ( $i = 1; $i <= $pages; $i++ ) {
if ( $i == $pg )
{ $lst_pgs .= "<b>$i</b> ";
$lst_pgshead .= "<b>$i</b> ";}
else $lst_pgs .= "<a <a style='text-decoration: none' href='index.php?".$q."&pg=$i'>$i</a> ";
}
if ( $pg < $pages) {
if ($pg == 1) {$nxtpg =2;} else {$nxtpg = $pg+1;}
$lst_pgs .= "<a style='text-decoration: none' href='index.php?".$q."&pg=".$nxtpg."'>>></a></div> ";
}
return $lst_pgs;
return $lst_pgshead;
}
?>
4.) Erstellt eine Datei "listpages.php" im Ordner "phpwcms_template/inc_script/frontend_render" mit folgendem Inhalt:
Code: Select all
<?
if (!$_GET["id"]) {$content["all"] = str_replace('{LISTPAGES}', $lstpg, $content["all"]);}
else {$content["all"] = str_replace('{LISTPAGES}', "", $content["all"]);}?>
5.) in eurem Template, fügt
an die Stelle, wo die Seiten aufgezählt werden sollen.
6.) Rest wie im ersten Beitrag beschrieben:
#-----[ OPEN ]---------------------------------------
#
include/inc_front/front.func.inc
//rewrite the function get_actcat_articles_data
Code: Select all
function get_actcat_articles_data ($act_cat_id, $dbcon) {
//returns the complete active and public article data as array (basic infos only)
//so it is reusable by many functions -> lower db access
$data = array();
$ao = get_order_sort($GLOBALS['content']['struct'][ $act_cat_id ]['acat_order']);
$sql = "SELECT *, UNIX_TIMESTAMP(article_tstamp) AS article_date FROM ".DB_PREPEND."phpwcms_article ";
$sql .= "WHERE article_cid=".intval($act_cat_id);
// VISIBLE_MODE: 0 = frontend (all) mode, 1 = article user mode, 2 = admin user mode
switch(VISIBLE_MODE) {
case 0: $sql .= " AND article_public=1 AND article_aktiv=1";
break;
case 1: $sql .= " AND article_uid=".$_SESSION["wcs_user_id"];
break;
//case 2: admin mode no additional neccessary
}
$sql .= " AND article_deleted=0 AND article_begin < NOW() AND article_end > NOW() ";
$sql .= "ORDER BY ".$ao[2];
//start hack by Viet Son//
$result_ts = mysql_query($sql, $dbcon);
$num_recs = mysql_num_rows($result_ts);
mysql_free_result($result_ts);
$pglen = $GLOBALS["template_default"]["record_per_page"];
if ($num_recs > $rec_page){
$pg = $_GET["pg"];
if(!$pg || $pg == 1){$start = 0;$pg = 1;}
else{$offset = $pg-1; $start = ($offset * $pglen); }
$sql1 = "SELECT acat_alias FROM ".DB_PREPEND."phpwcms_articlecat WHERE acat_id=".$act_cat_id.";";
if($result1 = mysql_query($sql1, $dbcon))
{
if($row = mysql_fetch_row($result1)) {$qrystr = $row[0];}
}//mysql_free_result($result1);
$lstpg = pager($pg,$pglen,$num_recs,$qrystr);
$GLOBALS["lstpg"]= $lstpg;
$sql .= " LIMIT $start,$pglen";
} else {$sql .=";";}
//END page list hack/////
if($result = mysql_query($sql, $dbcon)) {
while($row = mysql_fetch_assoc($result)) {
$data[$row["article_id"]] = array(
"article_id" => $row["article_id"],
"article_cid" => $row["article_cid"],
"article_title" => $row["article_title"],
"article_subtitle" => $row["article_subtitle"],
"article_keyword" => $row["article_keyword"],
"article_summary" => $row["article_summary"],
"article_redirect" => $row["article_redirect"],
"article_date" => $row["article_date"],
"article_username" => $row["article_username"],
"article_sort" => $row["article_sort"],
"article_notitle" => $row["article_notitle"],
"article_created" => $row["article_created"],
"article_image" => unserialize($row["article_image"]),
"article_timeout" => $row["article_cache"],
"article_nosearch" => $row["article_nosearch"]
);
}
mysql_free_result($result);
}
return $data;
}
#
# OPEN include/inc_front/content.func.inc
#
#
# ADD after <?php this line
#
Eventuell hab ich noch irgendwo was verändert, was ich jetzt nicht mehr weiß. Probiert's einfach mal