Bug #23627 Bug Fixed

preview fails on entries with pages module when pages tab is hidden

Version: 4.3.1 Reporter: bree

When using the pages module, if the pages tab and/or the pages template field is hidden in an edit layout, the preview panel always shows the homepage.
Is it possible to hide the page’s template drop down from the editor and still have a working preview?

  • Hi bree,

    I’ve got a fix in for the next release and posted it in the Solution tab. Give it a try and let me know if that that does indeed fix thins for you.

    Seth Barber
    05th June, 2018 at 2:37pm
  • thanks. just checking, line 408 currently has a closing curly brace on the if ($entry->hasPageURI()) conditional. Do you want me to paste that second bit before or after the closing brace on 408?

    bree
    05th June, 2018 at 2:44pm
  • That should be inside the conditional, so place it before the curly brace. The full conditional should look like

    if ($entry->hasPageURI())
    {
     $uri = $entry->getPageURI();
     ee()->uri->page_query_string = $entry->entry_id;
     if ( ! $template_id)
     {
      $template_id = $entry->getPageTemplateID();
     }
    }
    else
    {
     // We want to avoid replacing `{url_title}` with an empty string since that
     // can cause the wrong thing to render (like 404s).
     if (empty($entry->url_title))
     {
      $entry->url_title = $entry->entry_id;
     }
    
     $uri = str_replace(['{url_title}', '{entry_id}'], [$entry->url_title, $entry->entry_id], $channel->preview_url);
    }
    Seth Barber
    05th June, 2018 at 4:24pm

You must be signed in to comment on a bug report.

  • In system/ee/EllisLab/ExpressionEngine/Model/Channel/ChannelEntry.php add the following at line 1201:

    public function getPageTemplateID()
    {
        if ( ! $this->hasPageURI())
        {
         return NULL;
        }
    
        return $this->Site->site_pages[$this->site_id]['templates'][$this->getId()];
    }

    In system/ee/EllisLab/ExpressionEngine/Controller/Publish/Publish.php at line 408 add:

    if ( ! $template_id)
    {
        $template_id = $entry->getPageTemplateID();
    }
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases