简体   繁体   English

如何在Joomla中更改文章的布局?

[英]How to change layout for article in Joomla?

Is it possible in Joomla to override whole layout for article (not only article component layout)? 在Joomla中是否可以覆盖商品的整个布局(不仅是商品组件布局)? I have two columns website (with modules in right column) but for some articles i need one column design. 我有两栏网站(模块在右栏),但对于某些文章,我需要一栏设计。

Articles Associated with a Menu Item 与菜单项相关的文章

Edit the right column modules in Extensions -> Modules, and go to the Menu Assignment tab to disable modules on particular pages so that the sidebar collapses and the full width of the template will be used by the main content. 在“扩展”->“模块”中编辑右列模块,然后转到“菜单分配”选项卡以禁用特定页面上的模块,以便侧边栏折叠,并且模板的整个宽度将由主要内容使用。

Articles Not Associated with a Menu Item 与菜单项无关的文章

As far as I am aware, there is no provision for an article CSS class in the same way there is a page class for a menu item. 据我所知,没有提供CSS类文章的方式,就像为菜单项提供页面类的方式一样。

A crude way to implement this would be to install the free or paid version of Regular Labs Sourcerer or similar so that you can include some code in the article to dynamically add some CSS like this or similar: 实施此操作的一种粗略方法是安装Regular Labs Sourcerer或类似版本的免费或付费版本,以便您可以在文章中包含一些代码以动态添加类似此类的CSS:

<?php
$document = JFactory::getDocument();
$style = '.sidebar {'
          . 'display: none;'
          . '}'
          . '.main-content {'
          . 'width: 100%;'
          . '}';
$document->addStyleDeclaration($style);
?>

Even better, add the code to a custom HTML module (remember to set "Prepare Content" to "Yes" under the Options tab) with a custom module position such as full-width and then include the following code in the articles you wish to make full width: 更好的是,使用自定义模块位置(例如full-width )将代码添加到自定义HTML模块(请记住在“选项”选项卡下将“准备内容”设置为“是”),然后在您希望的文章中包含以下代码全宽:

{loadposition full-width}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM