Jump to content

Create multiple pages


mnybud

Recommended Posts

Can someone tell me how I would alter this code, which displays a list of my site pages as a single sitemap page, to generate multiple sitemap pages (like 20 links per sitemap page or something) with next and previous buttons? Trying to avoid having a ton of links on one page.....any help is appreciated!

 

<?php // SITEMAP
function sitemap($return = false) {
$sitemap = '';
$sitemap = '';
$keyword_file = file(FILE_KEYWORDS);
$keyword_file = array_map('trim', $keyword_file);
$keyword_file = str_replace(" ", "-", $keyword_file);
asort($keyword_file);
$letters = "";
$letters = explode(" ", $letters);
foreach($letters as $letter) {
	$links[$letter] = '';
	foreach($keyword_file as $keyword) {
		if (preg_match("/^$letter/i", $keyword)) {
			$links[$letter] .= $keyword." ";
		}
	}
	$links[$letter] = rtrim($links[$letter]);
	if ($links[$letter] !== '') {
		$links2 = explode(" ", $links[$letter]);
		$letter = str_replace("\d","#",$letter);
		$sitemap .= "\n"."<a name=\"".$letter."\" id=\"".$letter."\"></a>";
		$sitemap .= "\n"."<h1>".$letter."</h1>";
		foreach($links2 as $keyword) {
			$keyword = str_replace("-", " ", $keyword);
			$sitemap .= "\n".'<a href="http://'.THIS_DOMAIN.'/'.str_replace(" ", "-", $keyword).'" title="'.$keyword.'">'.$keyword.'</a><br />';
		}
	}
}
$sitemap .= "\n";
if ($return !== true) {
	print $sitemap;
}
else {
	return $sitemap;
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/62755-create-multiple-pages/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.