Preview feature and Categories Menu
5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 4, 2016 (RSS)
By Steve99 - February 1, 2016
Hello,
We're using v2.65 with a Category Menu section editor as the main Website Pages controller (in conjunction with the Permalinks plugin). The website navbar is dynamically generated, and the Website Pages content is effectively rendered via "selected category" in the List style. The kicker is we don't use a Detail page in this circumstance and the preview button displays our coded "not found" message if "no selected category". Is there a way to get a Category Menu Preview working for a List style view based on "selected category"?
Thank you,
Steve
By ross - February 2, 2016
Hi Steve
Thanks for posting.
What would you like to happen when you click the "preview" button? Do you just want to see the one article you are working on?
What's the URL to the front end page that displays all your records? Have your tried putting that in as the "preview" link in your section editor?
Let me know what you think. Thanks!
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
By Steve99 - February 2, 2016
Hi Ross,
The one record being worked on. We have no need for the "list" view preview (each record is an individual website page).
The "controller" page is called "/pages.php" and that was entered as the value for List Page, Detail Page, and Preview Page. (otherwise Permalinks plugin alert error to ensure admin user put a value in for each)
We use this one getCategories call:
// load records from 'site_pages'
list($site_pagesRecords, $selectedSite_pages) = getCategories(array(
'tableName' => 'site_pages',
'categoryFormat' => 'showall',
'defaultCategory' => '',
'rootCategoryNum' => '',
'ulAttributes' => '',
'selectedCategoryNum' => '',
'ulAttributesCallback' => 'customMenuUlAttr',
'liAttributesCallback' => 'customMenuLiAttr',
'loadCreatedBy' => false,
'loadUploads' => true,
'ignoreHidden' => false,
'debugSql' => false,
));
We then create the navigation menu based on this. The website page content is rendered according to "selected category" record.
Base example for page output:
<?php if (!$selectedSite_pages): ?>
<h1>Page Not Found</h1>
<p>Oops! The requested page could not be found!</p>
<?php endif ?>
<?php if ($selectedSite_pages): ?>
<h1><?php echo htmlencode($selectedSite_pages['name']) ?></h1>
<?php echo $selectedSite_pages['content']; ?>
<?php endif ?>
When clicking the "preview" button while doing "modify" a single record it triggers "if no selected pages".
Thank you,
Steve
By ross - February 4, 2016
Hi Steve
The problem you are running into here is that your front end page is setup as a "list page" and when you are clicking the Preview button, the preview system is expecting a "detail page".
Basically, this isn't going to work.
What you will want to look into is setting up a new front end page that's setup as a "detail page" and use that with your preview.
Does that make sense?
Let me know how you make out.
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/
By Steve99 - February 4, 2016
Hi Ross,
Okay, that most certainly makes sense. The original thought there was efficiency with a single getCategories database call, but obviously that's not going to work with the preview system. Aside from that item, the front end functionality and page load speed appeared to work well with that setup - however, we'd like to keep in line with best practices for working with CMSB and will update our code base accordingly. Thank you.
So just to recap, in order to have the preview system work as intended we'll have to use the getCategories call to handle creation of the website navigation and a separate getRecords call in the "detail" fashion to handle page rendering.
Cheers,
Steve