Script to display pages or posts for GetSimple CMS in sidebar

I was trying out the GetSimple CMS and although it looks pretty good, I was gutted that it didn’t display the pages/posts that you write. Usually the latest posts that you write appears in the sidebar but with GetSimple, you have to add the links manually. There’s the News Manager (or Extended News Manager) plugin that you can get but I couldn’t get it to work because of lack of documentation for the installation process.

Anyway I decided to look at the code and I managed to do a quick hack to display the pages in the sidebar of GetSimple. The code is as follows:

//display all pages except index page and private pages
$filenames = getFiles($path);

$pagesArray = array();
$heading = "<h2>Topics</h2>";
if (count($filenames) != 0)
	foreach ($filenames as $file)
		if (isFile($file, $path, 'xml'))
			$data = getXML($path .$file);
			$status = $data->menuStatus;
			$pagesArray[$count]['title'] = html_entity_decode($data->title, ENT_QUOTES, 'UTF-8');
			$pagesArray[$count]['parent'] = $data->parent;
			$pagesArray[$count]['menuStatus'] = $data->menuStatus;
			$pagesArray[$count]['private'] = $data->private;
			if ($data->parent != '')
				$parentdata = getXML($path . $data->parent .'.xml');
				$parentTitle = $parentdata->title;
				$pagesArray[$count]['sort'] = $parentTitle .' '. $data->title;
				$pagesArray[$count]['sort'] = $data->title;
			$pagesArray[$count]['url'] = $data->url;
			$pagesArray[$count]['date'] = $data->pubDate;
			$parentTitle = '';

			// do not show the index page as well as private pages
			if ($pagesArray[$count]['url'] != 'index' && $pagesArray[$count]['private'] != 'Y')
				$pages_list .= "<li><a href=\"/" . $pagesArray[$count]['url'] . "/\">" . $pagesArray[$count]['title'] . "</a></li>";

	if ($count > 0)
		$pages_list = $heading . "<ul>" . $pages_list . "</ul>";

	echo $pages_list;

You will need to paste the code where you want the list of pages to appear. I placed mine directly in the sidebar by going to “Edit Theme”. I don’t have time to make this into a GetSimple plugin but feel free to use it as you wish. The script will list all your pages except the index (homepage) and private pages. You can customise the heading and you can also easily list only 10 pages instead of everything by stopping the loop.

comments powered by Disqus