Joomla 2.5 中基于类别的文章的替代布局 [英] Alternative layout for article based on category in Joomla 2.5

查看:15
本文介绍了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;博士;- 我可以配置 Joomla 以根据该文章的类别设置文章级别的布局吗?

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

推荐答案

这是个好问题.也许您可以将默认布局设置为某种开关:将常规布局放在诸如 regular.php 之类的内容中,将特殊布局放入 like 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 中基于类别的文章的替代布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆