Przedszkolak
Postów: 28
Data rejestracji: 27.12.2006 10:58
|
Poniżej opisuje jak można dodać linki w górnej części kategorii artykułów, które po kliknięciu odświeżały by stronę i sortowały je.
Jak narazie to było testowanie tylko na mojej stronie.
Otwórz plik articles.php
Znajdź:
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY article_cat_name");
Zamień na:
// linki sortowania
echo "<center>".$locale['404'].": <a href=articles.php?sort_by=id>".$locale['405']."</a>, <a href=articles.php?sort_by=name>".$locale['406']."</a>, <a href=articles.php?sort_by=access>".$locale['407']."</a>, <a href=articles.php?sort_by=desc>".$locale['408']."</a></center>";
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY 'article_cat_name'");
// sortowanie
if (isset($sort_by)) {
if ($sort_by == "id") {
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY 'article_cat_id'");
} elseif ($sort_by == "name") {
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY 'article_cat_name'");
} elseif ($sort_by == "access") {
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY 'article_cat_access'");
} elseif ($sort_by == "desc") {
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY 'article_cat_description'");
}
}
Znajdź:
$rows = dbcount("(article_id)", "articles", "article_cat='$cat_id'");
if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
if ($rows != 0) {
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY ".$cdata['article_cat_sorting']." LIMIT $rowstart,15");
Po dodaj:
// linki sortowania
echo "<center>".$locale['404'].": <a href=articles.php?cat_id=$cat_id&sort_by=id>".$locale['405']."</a>, <a href=articles.php?cat_id=$cat_id&sort_by=name>".$locale['406']."</a>, <a href=articles.php?cat_id=$cat_id&sort_by=desc>".$locale['408']."</a>, <a href=articles.php?cat_id=$cat_id&sort_by=reads>".$locale['409']."</a></center>";
$rows = dbcount("(article_id)", "articles", "article_cat='$cat_id'");
if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
if ($rows != 0) {
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY ".$cdata['article_cat_sorting']." LIMIT $rowstart,15");
// sortowanie
if (isset($sort_by)) {
if ($sort_by == "id") {
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY 'article_id' LIMIT $rowstart,15");
} elseif ($sort_by == "name") {
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY 'article_subject' LIMIT $rowstart,15");
} elseif ($sort_by == "desc") {
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY 'article_snippet' LIMIT $rowstart,15");
} elseif ($sort_by == "reads") {
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY 'article_reads' LIMIT $rowstart,15");
}
}
Zapisz plik articles.php
Otwórz plik locale/Polish/articles.php
Znajdź:
$locale['403'] = "Brak Artykułów w tej Kategorii";
Po dodaj:
$locale['404'] = "Sortuj według";
$locale['405'] = "numeru";
$locale['406'] = "nazwy";
$locale['407'] = "dostępu";
$locale['408'] = "opisu";
$locale['409'] = "ilosci czytań";
$locale['410'] = "Czytań";
Jeśli chcesz zobaczyć jak to wygląda to wejdź na moją stronę (link w sygnaturze) i przejdź do działu Artykuły (trochę skromny on jest :)).
Edytowane przez daris dnia 01.01.2007 11:04:26
|
Bywalec
Postów: 915 Pomógł: 41
Data rejestracji: 12.03.2006 07:28
|
wszystko fajnie :D tylko przydala by sie mala optymalka z zabespieczonkiem :D oto i ona
<?php
/*--------------------------------------------+
| PHP-Fusion 5 - Content Management System |
|---------------------------------------------|
| author: Nick Jones (Digitanium) © 2002-2005 |
| web: http://www.php-fusion.co.uk |
| email: |
|---------------------------------------------|
| Released under the terms and conditions of |
| the GNU General Public License (Version 2) |
+--------------------------------------------*/
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
include LOCALE.LOCALESET."articles.php";
if (!isset($cat_id)) {
opentable($locale['400']);
[b]// linki sortowania
echo "<center>".$locale['404'].": <a href=articles.php?sort_by=id>".$locale['405']."</a>, <a href=articles.php?sort_by=name>".$locale['406']."</a>, <a href=articles.php?sort_by=access>".$locale['407']."</a>, <a href=articles.php?sort_by=description>".$locale['408']."</a></center>";
// sortowanie
$sortuj = "name";
$zab = preg_match("#(id|name|access|description)#si", $sort_by);
if (isset($sort_by) && $zab) $sortuj = $sort_by;
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY 'article_cat_".$sortuj."'");
[/b]
$rows = dbrows($result);
if ($rows != 0) {
$counter = 0; $columns = 2;
echo "<table cellpadding='0' cellspacing='0' width='100%' class='tbl'>\n<tr>\n";
while ($data = dbarray($result)) {
if ($counter != 0 && ($counter % $columns == 0)) echo "</tr>\n<tr>\n";
$num = dbcount("(article_cat)", "articles", "article_cat='".$data['article_cat_id']."'");
echo "<td align='center' valign='top' width='50%'><a href='".FUSION_SELF."?cat_id=".$data['article_cat_id']."'>".$data['article_cat_name']."</a> <span class='small2'>($num)</span>";
if ($data['article_cat_description'] != "") echo "<br>\n<span class='small'>".$data['article_cat_description']."</span>";
echo "</td>\n";
$counter++;
}
echo "</tr>\n</table>\n";
} else {
echo "<center><br>\n".$locale['401']."<br><br>\n</center>\n";
}
closetable();
} else {
$res = 0;
if (!isNum($cat_id)) fallback(FUSION_SELF);
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE article_cat_id='$cat_id'");
if (dbrows($result) != 0) {
$cdata = dbarray($result);
if (checkgroup($cdata['article_cat_access'])) {
$res = 1;
opentable($locale['400'].": ".$cdata['article_cat_name']);
[b]echo "<center>".$locale['404'].": <a href=articles.php?cat_id=$cat_id&sort_by=id>".$locale['405']."</a>, <a href=articles.php?cat_id=$cat_id&sort_by=subject>".$locale['406']."</a>, <a href=articles.php?cat_id=$cat_id&sort_by=snippet>".$locale['408']."</a>, <a href=articles.php?cat_id=$cat_id&sort_by=reads>".$locale['409']."</a></center>";[/b]
$rows = dbcount("(article_id)", "articles", "article_cat='$cat_id'");
if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
if ($rows != 0) {
[b]$sort = $cdata[article_cat_sorting];
$zab = preg_match("#(id|subject|snippet|reads)#si", $sort_by);
if (isset($sort_by) && $zab) $sort = "article_".$sort_by;
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY ".$sort." LIMIT $rowstart,15");[/b]
$numrows = dbrows($result); $i = 1;
while ($data = dbarray($result)) {
if ($data['article_datestamp']+604800 > time()+($settings['timeoffset']*3600)) {
$new = " <span class='small'>[".$locale['402']."]</span>";
} else {
$new = "";
}
echo "<a href='readarticle.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a>$new<br>\n".stripslashes($data['article_snippet']);
echo ($i != $numrows ? "<br><br>\n" : "\n"); $i++;
}
closetable();
if ($rows > 15) echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,15,$rows,3,FUSION_SELF."?cat_id=$cat_id&")."\n</div>\n";
} else {
echo "<center>".$locale['403']."</center>\n";
closetable();
}
}
}
if ($res == 0) redirect(FUSION_SELF);
}
require_once "side_right.php";
require_once "footer.php";
?>
Pozdro!! |
Przedszkolak
Postów: 28
Data rejestracji: 27.12.2006 10:58
|
Dzięki slawekneo. Przyda się w drobnej zmiance, którą zamieszczam poniżej.
W zmianach modyfikacji podlega już tylko plik articles.php (chyba że ktoś jeszcze nie ma zmodyfikowanego pliku locale/Polish/articles.php to niech zmodyfikuje według wskazówek napisanych w pierwszym poście).
Otwórz plik articles.php
Znajdź: (jeśli nie masz modyfikowanego pliku według pierwszego postu)
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY article_cat_name");
Zamień na:
// linki sortowania
echo "<center>".$locale['404'].": ";
// id
if ($sort_by != "id") {
echo "<a href=articles.php?sort_by=id>".$locale['405']."</a>, ";
} else {
echo "<b>".$locale['405']."</b>, ";
}
// name
if ($sort_by != "name") {
echo "<a href=articles.php?sort_by=name>".$locale['406']."</a>, ";
} else {
echo "<b>".$locale['406']."</b>, ";
}
// access
if ($sort_by != "access") {
echo "<a href=articles.php?sort_by=access>".$locale['407']."</a>, ";
} else {
echo "<b>".$locale['407']."</b>, ";
}
// description
if ($sort_by != "description") {
echo "<a href=articles.php?sort_by=description>".$locale['408']."</a>, ";
} else {
echo "<b>".$locale['408']."</b>, ";
}
echo "</center>";
// sortowanie
$sortuj = "name";
$zab = preg_match("#(id|name|access|description)#si", $sort_by);
if (isset($sort_by) && $zab) $sortuj = $sort_by;
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY 'article_cat_".$sortuj."'");
Znajdź:
$rows = dbcount("(article_id)", "articles", "article_cat='$cat_id'");
if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
if ($rows != 0) {
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY ".$cdata['article_cat_sorting']." LIMIT $rowstart,15");
Zamień na:
// linki sortowania
echo "<center>".$locale['404'].": ";
// id
if ($sort_by != "id") {
echo "<a href=articles.php?cat_id=$cat_id&sort_by=id>".$locale['405']."</a>, ";
} else {
echo "<b>".$locale['405']."</b>, ";
}
// subject
if ($sort_by != "subject") {
echo "<a href=articles.php?cat_id=$cat_id&sort_by=subject>".$locale['406']."</a>, ";
} else {
echo "<b>".$locale['406']."</b>, ";
}
// snippet
if ($sort_by != "snippet") {
echo "<a href=articles.php?cat_id=$cat_id&sort_by=snippet>".$locale['408']."</a>, ";
} else {
echo "<b>".$locale['408']."</b>, ";
}
// reads
if ($sort_by != "reads") {
echo "<a href=articles.php?cat_id=$cat_id&sort_by=reads>".$locale['409']."</a>";
} else {
echo "<b>".$locale['409']."</b>";
}
echo "</center>";
$rows = dbcount("(article_id)", "articles", "article_cat='$cat_id'");
if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
if ($rows != 0) {
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY ".$cdata['article_cat_sorting']." LIMIT $rowstart,15");
// sortowanie
$sort = $cdata[article_cat_sorting];
$zab = preg_match("#(id|subject|snippet|reads)#si", $sort_by);
if (isset($sort_by) && $zab) $sort = "article_".$sort_by;
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id' ORDER BY ".$sort." LIMIT $rowstart,15");
I teraz jeszcze prosiłbym o poprawki (szczególnie w tym długim fragmencie kodu "if ..." :D ) bo pewnie da się jakoś to skrócić.
Zamieszczam także gotowy plik articles.php extreme-fusion III (bo na nim aktualnie mam stronę).
daris dodał/a następującą plik:
Edytowane przez daris dnia 04.01.2007 16:50:01
|
Przedszkolak
Postów: 12
Data rejestracji: 05.12.2007 23:28
|
Dołączam się do leoncjo szukam segregowania artykułów po literce tak jak w wyszukiwaniu użytkowników.
EDIT: Witam, trochę sam pogrzebałem i zobaczcie do czego doprowadziłem. Niestety nie wiem dlaczego się tak dzieje jak się dzieję sami zobaczcie (http://urbantasty.com/articles.php?cat_id=4) na dole można wybrać literkę, ale wyskakuje dziwny błąd.
KOLEJNY EDIT: Razem z użytkownikiem sławekneo udało mi się zrobić segregację według literki na pewno każdemu się to przyda! Pozdrawiam
<?php
/*--------------------------------------------+
| PHP-Fusion 5 - Content Management System |
|---------------------------------------------|
| author: Nick Jones (Digitanium) ê 2002-2005 |
| web: http://www.php-fu... |
| email: |
|---------------------------------------------|
| Released under the terms and conditions of |
| the GNU General Public License (Version 2) |
+--------------------------------------------*/
require_once "maincore.php";
require_once "subheader.php";
// panele
$table = "panels_article";
require_once "side_left.php";
include LOCALE.LOCALESET."articles.php";
if ($rows != 0) {
opentable($locale['400']);
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE ".groupaccess('article_cat_access')." ORDER BY article_cat_name");
$rows = dbrows($result);
if ($rows != 0)
if (!isset($cat_id))
{
$counter = 0; $columns = 2;
echo "<table border='0' cellpadding='0' cellspacing='0' width='100%' class='tbl'>\n<tr>\n";
while ($data = dbarray($result)) {
if ($counter != 0 && ($counter % $columns == 0)) echo "</tr>\n<tr>\n";
$num = dbcount("(article_cat)", "articles", "article_cat='".$data['article_cat_id']."'");
($data['article_cat_thumbnail'] == "" ? $thmb = "_brak.gif" : $thmb = $data['article_cat_thumbnail']);
echo "<td valign='top' width='50%'>
<table width='100%'><tr>
<td width='1%'>";
echo "<table cellspacing='0' cellpadding='0' border='0'><tr>\n";
echo "<td><img src='".IMAGES."avatar_mod/gora_lewa.png' height='12' width='12'></td>\n";
echo "<td><img src='".IMAGES."avatar_mod/gora_srodek.png' height='12' width='100%'></td>\n";
echo "<td><img src='".IMAGES."avatar_mod/gora_prawa.png' height='12' width='12'></td></tr>\n";
echo "<td align='left'><img src='".IMAGES."avatar_mod/srodek_lewa.png' width='12' height='100%'></td>\n";
echo "<td align='center' height='1%'>";
echo "<img src='".IMAGES."article_cats/".$thmb."' height='50' width='50'></td>";
echo "<td align='right'><img src='".IMAGES."avatar_mod/srodek_prawa.png' height='100%' width='12'></td></tr><tr>\n";
echo "<td><img src='".IMAGES."avatar_mod/dol_lewa.png' height='12' width='12'></td>\n";
echo "<td><img src='".IMAGES."avatar_mod/dol_srodek.png' height='12' width='100%'></td>\n";
echo "<td><img src='".IMAGES."avatar_mod/dol_prawa.png' height='12' width='12'></td></tr>\n";
echo "</tr></table></td>
<td valign='top'><div class='tbl1'><a href='".FUSION_SELF."?cat_id=".$data['article_cat_id']."'>".$data['article_cat_name']."</a> <span class='small2'>($num)</span></div>";
if ($data['article_cat_description'] != "") echo "\n<span class='small'>".$data['article_cat_description']."</span>";
echo "</td>
</tr></table>";
echo "</td>\n";
$counter++;
}
echo "</tr>\n</table>\n";
} else {
echo "<center><br>\n".$locale['401']."<br><br>\n</center>\n";
}
closetable();
} else {
$res = 0;
if (!isNum($cat_id)) fallback(FUSION_SELF);
$result = dbquery("SELECT * FROM ".$db_prefix."article_cats WHERE article_cat_id='$cat_id'");
if (dbrows($result) != 0) {
$cdata = dbarray($result);
if (checkgroup($cdata['article_cat_access'])) {
$res = 1;
opentable($cdata['article_cat_name']);
if (!isset($sortby) || !preg_match("/^[A-Z 0-9]$/", $sortby)) $sortby = "all";
if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
$orderby = ($sortby == "all" ? "" : " AND article_subject LIKE '".stripinput($sortby)."%'");
$result = dbquery("SELECT * FROM ".$db_prefix."articles WHERE article_cat='$cat_id'".$orderby." ORDER BY ".$cdata['article_cat_sorting']." LIMIT $rowstart,15");
$rows = dbrows($result);
if ($rows != 0) {
$numrows = dbrows($result); $i = 1;
while ($data = dbarray($result)) {
if ($data['article_datestamp']+604800 > time()+($settings['timeoffset']*3600)) {
$new = " <span class='small'>[".$locale['402']."]</span>";
} else {
$new = "";
}
echo "<a href='readarticle.php?article_id=".$data['article_id']."'>".$data['article_subject']."</a>$new<br>\n".stripslashes($data['article_snippet']);
echo ($i != $numrows ? "<br><br>\n" : "\n"); $i++;
}
$search = array(
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
"S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"
);
echo "<hr>\n<table align='center' cellpadding='0' cellspacing='1' class='tbl-border'>\n<tr>\n";
echo "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."&sortby=all'>".$locale['404']."</a></td>";
for ($i=0;$i < 36!="";$i++) {
echo "<td align='center' class='tbl1'><div class='small'><a href='".FUSION_SELF."?cat_id=".$cdata['article_cat_id']."&sortby=".$search[$i]."'>".$search[$i]."</a></div></td>";
echo ($i==17 ? "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."&sortby=all'>".$locale['404']."</a></td>\n</tr>\n<tr>\n" : "\n");
}
echo "</tr>\n</table>\n";
closetable();
if ($rows > 15) echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,15,$rows,3,FUSION_SELF."?cat_id=$cat_id&")."\n</div>\n";
} else {
echo "<center>".$locale['403']."</center>\n";
echo "<center>na wybrana literke ".$sortby." niema zadnych artykulow</center>\n";
$search = array(
"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
"S","T","U","V","W","X","Y","Z","0","1","2","3","4","5","6","7","8","9"
);
echo "<hr>\n<table align='center' cellpadding='0' cellspacing='1' class='tbl-border'>\n<tr>\n";
echo "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."&sortby=all'>".$locale['404']."</a></td>";
for ($i=0;$i < 36!="";$i++) {
echo "<td align='center' class='tbl1'><div class='small'><a href='".FUSION_SELF."?cat_id=".$cdata['article_cat_id']."&sortby=".$search[$i]."'>".$search[$i]."</a></div></td>";
echo ($i==17 ? "<td rowspan='2' class='tbl2'><a href='".FUSION_SELF."&sortby=all'>".$locale['404']."</a></td>\n</tr>\n<tr>\n" : "\n");
}
echo "</tr>\n</table>\n";
closetable();
}
}
}
if ($res == 0) redirect(FUSION_SELF);
}
require_once "side_right.php";
require_once "footer.php";
?>
Edytowane przez merc39 dnia 08.12.2007 22:57:36
|