如何在不同的 Drupal 主题上显示不同的视图

发布于 2024-10-13 10:42:48 字数 275 浏览 3 评论 0原文

假设我的 drupal 站点有一个默认主题。在这里,我创建了视图、块等,并按照我想要的方式为公众设计了所有内容。现在,作为管理员,我希望有一个完全独立的主题。没问题,我在主题目录中创建第二个主题并将我的管理员用户主题配置切换到第二个主题。但是,如果在我的第二个主题中我想显示完全不同的内容(即视图、块等)怎么办? 让我们以我的首页为例(正面)。 现在我的首页有一个使用视图的幻灯片。无论我使用什么主题,该视图显然都会显示在首页上。因此,对于我的首页,如何为第二个主题显示与第一个主题使用的幻灯片视图完全不同的视图(例如博客文章列表)?

Say I have a default theme for my drupal site. Here I have created views, blocks, etc and styled everything the way I want for the public. Now, as the admin I would like to have an entirely separate theme. No problem, I create a second theme in the themes directory and switch my admin user theme configuration to the second theme. But, what if in my second theme I want to show entirely different content (i.e. Views, blocks, etc).
Let's use my front page as an example (front).
Right now my front page has a slideshow using Views. This view obviously shows up on the front page no matter what theme I'm using. So for my front page, how could I show an entirely different View (say a list of blog posts) for the second theme than the slideshow View I'm using for the first theme?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

去了角落 2024-10-20 10:42:48

最简单的方法是将视图放入块中,因为块是按主题配置的。不同的主题可以有完全不同的块配置。这种方法的一个潜在问题是,它确实需要做更多的工作才能让参数之类的东西与块中托管的视图很好地配合。

另一个可能对您有用的选择是以不同的方式使用相同的视图主题。视图与 Drupal 的主题层配合得非常好,您可以为特定视图或视图显示创建模板文件。查看视图管理页面中的主题信息链接,以查看视图的所有可能的覆盖。当然,这是假设您想要展示的内容之间存在一些共同元素。

第三种选择可能是在一页上显示多个视图,并使用权限系统确保任何一次只显示一个视图。我过去曾使用过这种方法,但管理起来确实有点笨拙,因为随着需求的变化,我必须在多个视图之间复制更改。

The easiest way is to put your views in a block, as blocks are configured per theme. Different themes can have completely different block configurations. A potential issue with this approach is that it does take some more work to get things like arguments to play nicely with views that are hosted in blocks.

Another option which may work for you is to just have the same view themed different ways. Views plays very nicely with the theme layer of Drupal and you can create template files for a particular view or view display. Check out the theme info link in the views admin page to see all the possible overrides for a view. Of course this is assuming that there are some common elements between what you want to show.

A third option might be to display multiple views on the one page, and use the permissions system to ensure only one is shown at any one time. I have used this approach in the past but it did get somewhat unwieldy to manage because as requirements changed I had to replicate the changes across multiple views.

战皆罪 2024-10-20 10:42:48

如果问题是关于在不同路径上触发的管理主题,并且块具有路径可见性设置。视图不仅仅出现在页面上,如果它们位于块中,则进行处理,如果不是——它们如何出现在页面上?

至于前面,如果你说有两个主题并且用户可以切换,那么你需要自己的“路由代码”。对此没有任何支持。即,您需要自己的块,根据主题调用相关块。

If the question is about the admin theme that fires on different paths and blocks have path visibility settings. Views do not just appear on a page, if they are in a block, that's handled if not -- how do they appear on the page?

As for front, if you say have two themes and user can switch then you need your own "routing code". There is no support for this. Ie you need your own blocks that call out to the relevant blocks depending on the theme.

浅唱々樱花落 2024-10-20 10:42:48

这看起来像是两个相当新但非常强大的模块的奇妙应用。

上下文 - http://drupal.org/project/context空间 - http://drupal.org/project/spaces

面板 http://drupal.org/project/panels

两者都有允许您为页面设置上下文,根据各种条件更改输出。在您的情况下,标准将是查看页面的用户的角色。两者都比 CurtainDog 提供的技巧更方便,顺便说一句,这些技巧都是非常有效的方法。这两个模块的优点是它们使组织和选择过程更加理智和简单。

很难对其中一个提出建议,但简而言之:面板在界面中有更多选项,但在代码级别上有一些学习曲线。 上下文/空间在编程级别上非常容易使用,但需要更多编码才能完成大多数任务。我建议在做出任何一个承诺之前都尝试一下。有关两者的精彩讨论,请收听此播客

This seams like a wonder application of two fairly new but very powerful modules.

Context - http://drupal.org/project/context in conjunction with Spaces - http://drupal.org/project/spaces

or

Panels http://drupal.org/project/panels

Both have concepts that allow you to set a context for pages that changes the output based on a variety of criteria. In your case the criteria would be the role of the user viewing the page. Both more less unwieldy than the tricks that CurtainDog offered up, which btw are all very valid approaches. The advantage of these two modules is that they make the organization and selection process much more sane and simple.

It's difficult to advise one over the other, but in a nutshell: Panels has more options in the interface, but has a bit of a learning curve on the code level. Context / Spaces is very easy to work with on the programing level, but required more coding to accomplish most tasks. I would suggest trying both before committing to either. For a wonderful discussion of both listen to this podcast.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文