Open Xendiadyon opened 7 years ago
This seems not a valid solution.
You can add 'tl_news' to the switch block and define $layout=false
and you can use the hook
Thank you for your quick answer. We do not want to pick styles for tl_news (yet).
The problem is that in the table tl_content (corresponding switch block tl_content), there are entries which belong to tl_article and entries which belong to tl_news. This can be distinguished by ptable:
Now, if we deal with content in articles in pages, you can find out the layout and filter by layout. But if we deal with content in news in news-reader-modules in articles in pages, you can never clearly define which layout is used, as you can define multiple news-reader-modules in different articles/pages having different layouts. In this case, the "layout" definition is obsolete.
What you now do is to check the tl_content.pid in tl_article (for example tl_article.id = 229) which gives you the section "header" (which has nothing to do with the actual placement of the news-entry) and the parent page id 30.
Querying the tl_page.id = 30, you might get a layout (here: layout-id 7 which does not exist anymore). This layout (if returned) has nothing to do with the actual layout of the news-entry.
If a (faulty) parent article is found (when tl_article.id = 229 as well as tl_news.id = 229), the default condition of the switch block is not performed.
Thus, the most convenient hack is to skip the layout and section definition (l. 89)
case 'tl_content':
$objContent = $this->Database->prepare("SELECT type,pid,ptable FROM tl_content WHERE id=?")->limit(1)->execute($id);
$id = $objContent->pid;
$cond = $objContent->type;
if ($objContent->ptable == "tl_news") break; // if we deal with news, use all layouts and all sections
if custom sections were implemented #24, one could argue to set $sec to the custom section "news".
The best solution would be to add options for news and news-elements to stylepicker. But this would be too complicated right now.
If we edit content in tl_news, we do not have layouts defined and thus we can't select any styles. We want to skip the layout query if we are dealing with entries in tl_news. Hence, we are able to pick all styles.
Fixing #25