5中类别的文章的替代布局

5中类别的文章的替代布局

本文介绍了基于Joomla 2.5中类别的文章的替代布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在Joomla 2.5安装中为文章提供2个版式"

I currently have 2 'layouts' for articles in my Joomla 2.5 install

default.php
default_links.php
feature_link.php
feature_link.php

当在文章布局"下的文章管理器"的编辑文章"屏幕中选择每个项目时,它们将按预期工作.

which work as intended when each is selected in the 'Edit Article' screen of the 'Article Manager' under 'Alternative Layouts'.

但是,我希望某个类别中的文章可以使用一种布局自动显示,而其他所有文章则可以使用另一种布局自动显示.

However, I'd like articles in a certain category to automatically display using one layout, and all other articles to display using the other.

我看到您可以在类别管理器"下选择替代布局",但这将在"com_content"的类别"视图中指定布局(与该类别中文章的布局相对).

I see you can select 'Alternative Layout' under the 'Category Manager', but this specifies the layout in 'Category' view of 'com_content' (as opposed to the layout of the articles WITHIN that category).

在创建类别博客"菜单项时,我还浏览了作为参数的文章选项",但是令人沮丧的是,您无法在此处覆盖或指定替代布局",这似乎是最明显的地方.

I've also taken a look through the 'Article Options' available as parameters when creating a 'Category Blog' menu item, however frustratingly you can't override or specify 'Alternative Layout' here - which would seem like the most obvious place.

TL; DR; -我可以配置Joomla以根据该文章的类别设置文章级布局吗?

TL;DR; - can I configure Joomla to set article-level layout based on the category of that article ?

推荐答案

那是一个很好的问题.也许您可以对默认布局进行某种切换:将常规布局放在诸如regular.php之类的特殊布局中,并将诸如special.php之类的特殊布局放入,并让default.php查找该文章所属的类别.然后包括各个布局文件的代码...只是一个想法.

Well thats a good question. Maybe you could make your default layout some kind of a switch: Put the regular layout in something like regular.php and the special in like special.php and have the default.php discover which category the article belongs to. Then include the code of the respective layout file... Just an idea.

喜欢这个...

default.php:

default.php:

<?php
   ...
   $specialCategory = 42; // the id of your special category
   if($this->item->catid == $specialCategory){
       include "special.php";
   }else{
       include "regular.php";
   }
?>

请注意,到目前为止我还没有尝试...

Please note that I did not try so far...

我刚刚在com_users登录视图中找到了它:

I just found this in the com_users login view:

default.php

default.php

if ($this->user->get('guest')):
// The user is not logged in.
echo $this->loadTemplate('login');
else:
// The user is already logged in.
echo $this->loadTemplate('logout');
endif;

tmp文件夹中的文件名为default.php,default_login.php和default_logout.php.

The files in the tmp folder are named default.php, default_login.php and default_logout.php.

这篇关于基于Joomla 2.5中类别的文章的替代布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 08:54