Is there a way to the same detail page template for different sections?
2 posts by 1 authors in: Forums > CMS Builder
Last Post: 10 hours ago (RSS)
By jasmar222 - 11 hours ago - edited: 11 hours ago
Currently, I have a set up like this:
- About pages > /pgs/about-pages.php
- Contact pages > /pgs/contact-pages.php
- Service pages > /pgs/service-pages.php
Note, I am using the Permalinks plugin.
But I was wondering if there is a way for me to use the same page template for all of the sections?
- About pages > /pgs/pages.php
- Contact pages > /pgs/pages.php
- Service pages > /pgs/pages.php
By jasmar222 - 10 hours ago
Ok, i think i have a working solution so I am sharing in case it's helpful to someone else:
<?php
header('Content-type: text/html; charset=utf-8');
include_once("../cmsb/lib/viewer_functions.php");
// get the URI and trim leading and trailing slashes
$uri = trim($_SERVER['REQUEST_URI'], '/');
// lookup the URI in the permalinks table to find the corresponding section
$section = mysql_get('cmsb__permalinks', null, [
'permalink' => $uri,
'old' => '0'
]);
// get the tablename for the section
if ($section) {
$tableName = $section['tableName'];
// and then load the page
list($page, $pageMetaData) = getRecords(array(
'tableName' => $tableName,
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$page = @$page[0]; // get first record
if (!$page) {
header("HTTP/1.1 301 Moved Permanently");
header("Location: /");
exit;
}
}
?>