Przedszkolak
Postów: 25 Ostrzeżeń: 2
v7.02.07 Data rejestracji: 15.02.2012 18:05
|
Witam,
przeprowadziłem modyfikację pliku news_cats.php.
Obecny rezultat jest widoczny tutaj: http://tomaszowia...s_cats.php
Po wybraniu którejś kategorii newsów, do adresu URL zostaje dodana wartość ID danej kategorii np: http://tomaszowia...p?cat_id=2
W tym przypadku wybraliśmy kategorię nr 2.
Jak widać limit ilości newsów ustawiony jest na 3. Pod listą newsów wygenerowałem tzw. page navigation, które prawidłowo się wyświetla, zliczając ilość newsów z wybranej kategorii i tworząc kolejne strony.
Mój problem/pytanie:
Co należy zmienić w kodzie pliku news_cats.php aby page navigation działało poprawnie. Czyli w URL juz oprócz samej deklaracji kategorii była widoczna wartość rowstart.
Np. ../news_cats.php?cat_id=2?rowstart=6. Czy jest możliwość edycji pliku news_cats.php w taki sposób aby móc wczytać z adresu 2 zmienne i odpowiednio do nich wyświetlć listę newsów?
Kod news_cats.php
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: news_cats.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."news_cats.php";
add_to_title($locale['global_200'].$locale['400']);
$items_per_page = 3;
if (isset($_GET['cat_id']) && isnum($_GET['cat_id'])) {
echo $_GET['rowstart'];
$res = 0;
$result = dbquery("SELECT news_cat_name FROM ".DB_NEWS_CATS." WHERE news_cat_id='".$_GET['cat_id']."'");
if (dbrows($result) || $_GET['cat_id'] == 0) {
$data = dbarray($result);
$rows = dbcount("(news_id)", DB_NEWS, "news_cat='".$_GET['cat_id']."' AND ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().") AND news_draft='0'");
if ($rows) {
$res = 1;
if ($_GET['cat_id'] != 0) { // tutaj lista jeżeli wybraliśmy kategorię
opentable2("".$data['news_cat_name']." ");
$result = dbquery("SELECT tn.*, tc.*, tu.user_id, tu.user_name, tu.user_status
FROM ".DB_NEWS." tn
LEFT JOIN ".DB_USERS." tu ON tn.news_name=tu.user_id
LEFT JOIN ".DB_NEWS_CATS." tc ON tn.news_cat=tc.news_cat_id
WHERE ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().")
AND (news_end='0'||news_end>=".time().") AND news_draft='0' AND news_cat='".$_GET['cat_id']."'
GROUP BY news_id
ORDER BY news_datestamp DESC LIMIT 2,".$items_per_page);
$numrows = dbrows($result);
echo $_GET['rowstart'];
$newsy_z_kategorii = $data['news_cat_id'];
echo "<div class='newsy-lista flatfix '><ul class='flatfix box1 clearfix'>"; // hotlista
while ($data = dbarray($result)) {
$wykluczone2[]=$data['news_id'];
$i++;
$comments = dbcount("(comment_id)", DB_COMMENTS." WHERE comment_type='N' AND comment_hidden='0' AND comment_item_id='".$data['news_id']."'");
$news_cat_image = "";
$news_subject = stripslashes($data['news_subject']);
if ($data['news_image_t2'] && $settings['news_image_frontpage'] == 0) {
$news_cat_image .= "<img src='".IMAGES_N_T.$data['news_image_t2']."' alt='".$data['news_subject']."' />";
} elseif ($data['news_cat_image']) {
$news_cat_image .= "<img src='".get_image("nc_".$data['news_cat_name'])."' alt='".$data['news_cat_name']."' />";
} else {
$news_cat_image = "";
}
$news_news = preg_replace("/<!?--\s*pagebreak\s*-->/i", "", ($data['news_breaks'] == "y" ? nl2br(stripslashes($data['news_news'])) : stripslashes($data['news_news'])));
$news_info = array(
"news_id" => $data['news_id'],
"user_id" => $data['user_id'],
"user_name" => $data['user_name'],
"user_status" => $data['user_status'],
"news_date" => $data['news_datestamp'],
"cat_id" => $data['news_cat'],
"cat_name" => $data['news_cat_name'],
"cat_image" => $news_cat_image,
"news_subject" => $data['news_subject'],
"news_ext" => "n",
"news_reads" => $data['news_reads'],
"news_comments" => dbcount("(comment_id)", DB_COMMENTS, "comment_type='N' AND comment_item_id='".$data['news_id']."' AND comment_hidden='0'"),
"news_allow_comments" => $data['news_allow_comments'],
"news_sticky" => $data['news_sticky'],
"news_lead" => $data['news_lead'],
"news_lead2" => $data['news_lead2'],
"news_galeria" => $data['news_galeria'],
"news_video" => $data['news_video']
);
render_news($news_subject, $news_news, $news_info);
$licz ++;
}
echo "</ul></div>";
if ($rows > $items_per_page) echo "<div align='center' style=';margin-top:5px;'>\n".makepagenav($_GET['rowstart'],$items_per_page,$rows,3)."\n</div>\n";
} else {
echo "kat = 0 ".$locale['403']."<br />\n";
echo "<strong>".$locale['401']."</strong> <p>$rows</p>\n";
}
$result2 = dbquery("SELECT news_id, news_subject FROM ".DB_NEWS." WHERE news_cat='".$_GET['cat_id']."' AND ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().") AND news_draft='0' ORDER BY news_datestamp DESC LIMIT 10");
while ($data2 = dbarray($result2)) {
echo THEME_BULLET." <a href='news.php?readmore=".$data2['news_id']."'>".$data2['news_subject']."</a><br />\n";
}
echo "".THEME_BULLET." <a href='".FUSION_SELF."'>".$locale['406']."</a>";
echo "<!--sub_news_cat-->\n";
}
}
if (!$res) { redirect(FUSION_SELF); }
closetable();
} else {
$res = 0;
$licz = "-2";
$result = dbquery("SELECT news_cat_id, news_cat_name FROM ".DB_NEWS_CATS." WHERE news_cat_id!='19' AND news_cat_id!='6' AND news_cat_id!='8' AND news_cat_id!='21' ORDER BY news_cat_id");
if (dbrows($result)) {
$wykluczone2[] = 0;
echo "<!--pre_news_cat_idx--><table cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n";
while ($data = dbarray($result)) {
$rows = dbcount("(news_id)", DB_NEWS, "news_cat='".$data['news_cat_id']."' AND ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().") AND news_draft='0'");
opentable2($data['news_cat_name']."<span>".$locale['402']." $rows <a href='".FUSION_SELF."?cat_id=".$data['news_cat_id']."' class='przeslij-nam-temat' >Zobacz wszystkie</a></span>");
if ($rows) {
$result2 = dbquery("SELECT tn.*, tc.*, tu.user_id, tu.user_name, tu.user_status
FROM ".DB_NEWS." tn
LEFT JOIN ".DB_USERS." tu ON tn.news_name=tu.user_id
LEFT JOIN ".DB_NEWS_CATS." tc ON tn.news_cat=tc.news_cat_id
WHERE ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().")
AND (news_end='0'||news_end>=".time().") AND news_draft='0' AND news_cat='".$data['news_cat_id']."'
GROUP BY news_id
ORDER BY news_datestamp DESC LIMIT 3");
$newsy_z_kategorii = $data['news_cat_id'];
//echo $wykluczone[];
echo "<div class='newsy-lista flatfix '><ul class='flatfix box1 clearfix'>"; // hotlista
while ($data = dbarray($result2)) {
$wykluczone2[]=$data['news_id'];
$i++;
$comments = dbcount("(comment_id)", DB_COMMENTS." WHERE comment_type='N' AND comment_hidden='0' AND comment_item_id='".$data['news_id']."'");
$news_cat_image = "";
$news_subject = stripslashes($data['news_subject']);
if ($data['news_image_t2'] && $settings['news_image_frontpage'] == 0) {
$news_cat_image .= "<img src='".IMAGES_N_T.$data['news_image_t2']."' alt='".$data['news_subject']."' />";
} elseif ($data['news_cat_image']) {
$news_cat_image .= "<img src='".get_image("nc_".$data['news_cat_name'])."' alt='".$data['news_cat_name']."' />";
} else {
$news_cat_image = "";
}
$news_news = preg_replace("/<!?--\s*pagebreak\s*-->/i", "", ($data['news_breaks'] == "y" ? nl2br(stripslashes($data['news_news'])) : stripslashes($data['news_news'])));
$news_info = array(
"news_id" => $data['news_id'],
"user_id" => $data['user_id'],
"user_name" => $data['user_name'],
"user_status" => $data['user_status'],
"news_date" => $data['news_datestamp'],
"cat_id" => $data['news_cat'],
"cat_name" => $data['news_cat_name'],
"cat_image" => $news_cat_image,
"news_subject" => $data['news_subject'],
"news_ext" => "n",
"news_reads" => $data['news_reads'],
"news_comments" => dbcount("(comment_id)", DB_COMMENTS, "comment_type='N' AND comment_item_id='".$data['news_id']."' AND comment_hidden='0'"),
"news_allow_comments" => $data['news_allow_comments'],
"news_sticky" => $data['news_sticky'],
"news_lead" => $data['news_lead'],
"news_lead2" => $data['news_lead2'],
"news_galeria" => $data['news_galeria'],
"news_video" => $data['news_video']
);
render_news($news_subject, $news_news, $news_info);
$licz ++;
}
echo "</ul></div>";
$result3 = dbquery("SELECT news_subject, news_lead2, news_id FROM ".DB_NEWS."
WHERE ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().")
AND (news_end='0'||news_end>=".time().") AND news_draft='0' AND news_cat='".$newsy_z_kategorii."'
AND news_id!='".$wykluczone2[0+$licz]."'
AND news_id!='".$wykluczone2[1+$licz]."'
AND news_id!='".$wykluczone2[2+$licz]."'
GROUP BY news_id
ORDER BY news_datestamp DESC LIMIT 5");
while ($data = dbarray($result3)) {
echo "<p>".THEME_BULLET." <a href='news.php?readmore=".$data['news_id']."'>";
if($data['news_lead2'] !== ""){
echo "<span class='hot-tresc'>".$data['news_lead2']."</span> ";}
echo $data['news_subject']."</a></p>\n";
}
} else {
echo THEME_BULLET." ".$locale['404']."\n";
}
closetable2();
}
$res = 1;
}
$result = dbquery("SELECT * FROM ".DB_NEWS." WHERE news_cat='0' AND ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().") AND news_draft='0' ORDER BY news_datestamp DESC LIMIT 10");
if (dbrows($result)) {
if ($res == 0) { echo "<table cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>\n"; }
$nrows = dbcount("(news_id)", DB_NEWS, "news_cat='0' AND ".groupaccess('news_visibility')." AND (news_start='0'||news_start<=".time().") AND (news_end='0'||news_end>=".time().") AND news_draft='0'");
echo "<tr>\n<td width='150' class='tbl1' style='vertical-align:top'>".$locale['403']."<br />\n";
echo "<strong>".$locale['402']."</strong> $nrows</td>\n<td class='tbl1' style='vertical-align:top'>\n";
while ($data = dbarray($result)) {
echo THEME_BULLET." <a href='news.php?readmore=".$data['news_id']."'>".$data['news_subject']."</a><br />\n";
}
$res = 1;
if ($nrows > 10) { echo "<div style='text-align:right'>".THEME_BULLET." <a href='".FUSION_SELF."?cat_id=0'>".$locale['405']."</a></div>\n"; }
echo "</td>\n</tr>\n";
}
if ($res == 1) {
echo "</table><!--sub_news_cat_idx-->\n";
} else {
echo "<div style='text-align:center'><br />\n".$locale['407']."<br /><br />\n</div>\n";
}
}
require_once THEMES."templates/footer.php";
?>
PW od moderatora:
- Przeniesienie tematu - Pieka 19.06.2015 18:34
www.tomaszowiak.tv
|