contao/test — Issue #805: Preview articles Bug
Author: importer
Created: 2011-11-28 17:27:25+00:00
State: closed
Labels: backend, Defect

If you want to preview an unpublished article it is always be displayed in the column main.
The column is not set in main.php.

Original Source (typolight/main.php :258):

```
// Preview article
if ($this->Input->get('do') == 'article' && strlen(CURRENT_ID))
{
$objPreview = $this->Database->prepare("SELECT p.id AS pid, p.alias AS palias, a.id AS aid, a.alias AS aalias FROM tl_article a, tl_page p WHERE a.id=? AND a.pid=p.id")
->limit(1)
->execute(CURRENT_ID);

if ($objPreview->numRows)
{
if ($GLOBALS['TL_CONFIG']['disableAlias'])
{
$this->Template->frontendFile = 'index.php?id=' . $objPreview->pid . '&articles=' . $objPreview->aid;
}
else
{
$this->Template->frontendFile = 'index.php/' . (strlen($objPreview->palias) ? $objPreview->palias : $objPreview->pid) . '/articles/' . (strlen($objPreview->aalias) ? $objPreview->aalias : $objPreview->aid) . $GLOBALS['TL_CONFIG']['urlSuffix'];
}
}
}
```

Possible Solution (tested with Alias enabled, adding column in sql statement and in creating of frontendFile var):

```
// Preview article
if ($this->Input->get('do') == 'article' && strlen(CURRENT_ID))
{
$objPreview = $this->Database->prepare("SELECT p.id AS pid, p.alias AS palias, a.id AS aid, a.alias AS aalias, a.inColumn AS aColumn FROM tl_article a, tl_page p WHERE a.id=? AND a.pid=p.id")
->limit(1)
->execute(CURRENT_ID);

if ($objPreview->numRows)
{
if ($GLOBALS['TL_CONFIG']['disableAlias'])
{
$this->Template->frontendFile = 'index.php?id=' . $objPreview->pid . '&articles=' . (strlen($objPreview->aColumn) ? $objPreview->aColumn : 'main') . ':' . $objPreview->aid;
}
else
{
$this->Template->frontendFile = 'index.php/' . (strlen($objPreview->palias) ? $objPreview->palias : $objPreview->pid) . '/articles/'. (strlen($objPreview->aColumn) ? $objPreview->aColumn : 'main') . ':' . (strlen($objPreview->aalias) ? $objPreview->aalias : $objPreview->aid) . $GLOBALS['TL_CONFIG']['urlSuffix'];
}
}
}
```

[Download the attachments](http://www.contao.org/tl_files/tickets/805.zip "Download the attachments of this ticket")

--- _Originally created by anonymous on June 15th, 2009, at 03:29pm (ID 805)_