Witam, mam skrypt artykułów.
Chciałem dodać do widoku artykułów możliwość przejścia do następnego i poprzedniego artykułu.
Kod php pliku zdjecie.php
Najlepiej gdybym mógł wstawić aby @następny do pliku tpl. @nastepny dotyczyłby adresu artykułu.
<?php
include('config.php');
//Create site settings variables
$sitequery = 'select * from settings;';
$siteurl = $siteinfo['url'];
$zdjecie = $_GET['id'];
header('Location: '.$siteurl); }
else
{
$sitequery = 'select * from settings;';
//Create site settings variables
$sitetitle = $siteinfo['title'];
$siteurl = $siteinfo['url'];
$sitecomments = $siteinfo['comments'];
$commentmod = $siteinfo['commentmod'];
$query = "select * from zdjecia where status=0 and id = ".$zdjecie;
if (!$num_results) {
header('Location: '.$siteurl); }
//Get zdjecie info
$id = $zdjecieinfo['id'];
$authorid = $zdjecieinfo['authorid'];
$artdate = date('m/d/y', $date); $fotografiaid = $zdjecieinfo['fotografiaid'];
$resource = $zdjecieinfo['resource'];
//Meta Info
$cathead = 0;
$metatitle = $title." - ";
include('header.php');
include('sidebar.php');
if ($seourls == 1) { $scrubtitle = generate_seo_link($title); }
// Setup the zdjecie template
$zdjecietemp = new Template("templates/".$template."/zdjecie.tpl");
// get author info
$authorquery = "select * from authors where id=".$authorid;
$authorname = $authorinfo['displayname'];
$authorbio = $authorinfo['bio'];
$gravatar = $authorinfo['gravatar'];
if ($seourls == 1) { $scrubauthor = generate_seo_link($authorname); }
// get fotografia info
$catquery = "select * from fotografie where id=".$fotografiaid;
$fotografianame = $catinfo['name'];
$catparent = $catinfo['parentid'];
if ($seourls == 1) { $scrubcatname = generate_seo_link($fotografianame); }
// if the fotografia doesn't have a parent
if ($catparent == NULL) {
if ($seourls == 1) { // With SEO URLS
$displaycat = "<a href=\"".$siteurl."/fotografia/".$fotografiaid."/"
.$scrubcatname."/\"><b>".$fotografianame."</b></a>";
} else {
$displaycat = "<a href=\"".$siteurl."/fotografia.php?id=".$fotografiaid
."\"><b>".$fotografianame."</b></a>";
}
// if the fotografia DOES have a parent
} else {
$query = "select * from fotografie where id=".$catparent;
$parentname = $info['name'];
if ($seourls == 1) { $scrubparent = generate_seo_link($parentname); }
if ($seourls == 1) { // With SEO URLS
$displaycat = "<a href=\"".$siteurl."/fotografia/".$catparent."/"
.$scrubparent."/\"><b>".$parentname."</b></a> >
<a href=\"".$siteurl."/fotografia/".$fotografiaid."/"
.$scrubcatname."/\"><b>".$fotografianame."</b></a>";
} else {
$displaycat = "<a href=\"".$siteurl."/fotografia.php?id=".$catparent
."\"><b>".$parentname."</b></a> >
<a href=\"".$siteurl."/fotografia.php?id=".$fotografiaid
."\"><b>".$fotografianame."</b></a>";
}
}
// Add a view to this zdjecie
$query = "select * from zdjecieviews where zdjecieid = ".$zdjecie;
if ($viewinfo == NULL) {
$sql = "INSERT INTO zdjecieviews VALUES (".$zdjecie.", 1)";
} else {
$totalviews = $viewinfo['views'];
$totalviews++;
$sql = "UPDATE zdjecieviews SET views=".$totalviews." WHERE `zdjecieid`=".$zdjecie."";
}
if ($seourls == 1) { // With SEO URLS
$authorlink = "<a href=\"".$siteurl."/profile/".$authorid."/".$scrubauthor."/\"><b>".$authorname."</b></a>";
} else {
$authorlink = "<a href=\"".$siteurl."/profile.php?a=".$authorid."\"><b>".$authorname."</b></a>";
}
// Setup all template variables for display
$zdjecietemp->set("authorname", $authorname);
$zdjecietemp->set("authorlink", $authorlink);
$zdjecietemp->set("date", $artdate);
$zdjecietemp->set("displaycat", $displaycat);
$zdjecietemp->set("views", $totalviews);
$zdjecietemp->set("title", $title);
$zdjecietemp->set("body", $body);
$zdjecietemp->set("gravatar", $gravatar);
$zdjecietemp->set("resource", $resource);
// For the adcode
$query = "select * from adboxes where id=1;";
$zdjecietemp->set("250adcode", stripslashes($info['adcode']));
// Outputs the homepage template!
echo $zdjecietemp->output();
# Setup db config array #
$db_config = array("db_name" => $db_name, "db_user" => $dbusername,
"db_pass" => $dbpassword,
"db_host" => $server );
include('rightsidebar.php');
}
?>
oraz tabela która przetrzymuje owe artykuły.
CREATE TABLE IF NOT EXISTS `zdjecia` (
`id` int(16) NOT NULL AUTO_INCREMENT,
`status` int(1) NOT NULL,
`authorid` int(16) NOT NULL,
`date` datetime NOT NULL,
`obrazek` varchar(256) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`title` varchar(256) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`fotografiaid` int(8) NOT NULL,
`parentid` int(8) DEFAULT NULL,
`body` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`resource` text CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`problem` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin2 AUTO_INCREMENT=75 ;
A sam link artykułu wyglada tak:
http://adres.pl/zdjecie.php?id=74