preview button and permalink not working

3 posts by 2 authors in: Forums > CMS Builder
Last Post: January 5, 2023   (RSS)

By kitsguru - January 4, 2023 - edited: January 5, 2023

I am using CMSB 3.57 with permalink 1.10 and experiencing an issue with multi-record editor.

It works fine with a category menu section. BUT with the multi-record editor I get a file not found error when clicking the preview button when editing a record. The record has been saved.

Both editors point to the appropriate detail page and the preview URL is left blank. 

list($blogRecords, $blogMetaData) = getRecords(array(
    'tableName'   => blog,
    'where'       => "blog.num='" . getLastNumberInUrl() . "'",
    'loadUploads' => true,
    'allowSearch' => false,
    'leftJoin'    => array(
        'bios' => 'biosNum'),
    'limit'       => '1',
    'debugSql'    => false,
));

I wonder if the where clause is causing the preview to fail. If so what should it be?

Jeff Shields

By Steve99 - January 5, 2023 - edited: January 5, 2023

Hi Jeff,

I've experienced this before. It's seeing the last number in url as 9999999999.

Try something like this, using the $blogPageWhere string to set your query (set from preview:num, or to use your normal page query):

if (getLastNumberInUrl() == '9999999999') { // if preview mode
$blogPreviewNum = intval( @$_REQUEST['preview:num'] );
$blogPageWhere  = "blog.num = $blogPreviewNum";
} else {
$blogPageWhere  = "blog.num='" . getLastNumberInUrl() . "'";
}

Hope this helps!

Best,
Steve