Hidden pages in Permalinks table

By Toledoh - January 14, 2016

Hi Guys.

If a page is "hidden", or outside of the publishDate / removeDate, is there any way to mark it as hidden, or "old" in the permalinks table?

I'm using this table to maintain the sitemap.xml, and google is looking at pages that are not currently published and therefore returning 404.

Cheers,

Tim (toledoh.com.au)

Hey Tim,

What code are you using to generate the sitemap? Could you post it here for me? It might be possible to add some code that checks if a particular record in a section is hidden or expired and stop it added.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Toledoh - January 14, 2016

Hey Greg.

This is the basic code I use.

<?php
/* STEP 1: LOAD RECORDS - Copy this PHP code block near the TOP of your page */

// load viewer library
$libraryPath = 'cmsb/lib/viewer_functions.php';
$dirsToCheck = array('/home/xxx/public_html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

// load records from '_permalinks'
list($_permalinksRecords, $_permalinksMetaData) = getRecords(array(
'tableName' => '_permalinks',
'orderBy' => '', // use default database order
'loadUploads' => false,
'allowSearch' => false,
));

?>
<?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<'.'?xml version="1.0" encoding="UTF-8"?>'; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

<?php foreach ($_permalinksRecords as $record): ?>
<?php if (!$record['old']): ?>
<url>

<loc>http://<?php echo $_SERVER['HTTP_HOST']; ?><?php echo $record['_link'] ?></loc>

<lastmod><?php echo date('Y-m-d', strtotime($record['updatedDate'])) ?></lastmod>

<changefreq>weekly</changefreq>


<priority>0.5</priority>

</url>
<?php endif ?>
<?php endforeach ?>

</urlset>

Cheers,

Tim (toledoh.com.au)

By Toledoh - January 14, 2016

Perfect - thanks!

Cheers,

Tim (toledoh.com.au)