在 Drupal 7 中,我创建了一个子主题,如何将该主题分配给特定页面?_

发布于 2024-10-20 19:20:47 字数 353 浏览 3 评论 0原文

所以我在 Drupal 7 中启用了我的父主题和子主题。

我在子主题的 .info 中指定基本主题是父主题。

创建页面后,如何告诉该页面继承我的子主题?

任何帮助将不胜感激。

编辑: 所以我想要做的是创建几个新页面(大约 20 个),这些页面将遵循与我的 Drupal 站点的其余部分相同的模板文件。然而,它们都有不同的背景图像、链接颜色和标题样式。我认为 Drupal 子主题可以让我创建一个继承主样式表的页面,但让我根据新页面的需要对其进行修改。听起来这不是子主题的用途。

感谢 Matt V: 子主题允许您使用现有主题作为创建自己的自定义主题的起点。

So I have my parent theme and my subtheme both enabled in Drupal 7.

I've specified in the .info of the subtheme that the base theme is the parent theme.

Once I create a page, how do I tell that page to inherit my subtheme?

Any help would be greatly appreciated.

EDIT:
So what I want to do is create several new pages (about 20) that are going to follow the same template file as the rest of my Drupal site. However, they are all going to have different background images, link colors, and heading styles. I figured the Drupal subthemes would let me create a page that inherits the main stylesheet, but lets me modify it as needed for the new pages. Sounds like that's not what subthemes are for.

Thanks to Matt V:
Subthemes allow you to use an existing theme as the starting point for creating your own custom theme.

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

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

发布评论

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

评论(4

紫罗兰の梦幻 2024-10-27 19:20:47

我可能是错的,但如果你想在不同的页面上实现不同的主题,听起来你要找的是“hook_custom_theme”,它非常简单,基本上你只需添加:

function mymodule_custom_theme(){
  //Some custom logic here
  $node=node_load(arg(1));
  if($node && $node->type=="my_custom_type"){
    return 'my_custom_theme';
  }
}

你的返回值必须是一个等于机器可读的字符串您要切换到的主题的名称...

重新阅读您的帖子,您可能需要查看 template_preprocess_html 和 template_preprocess_page 函数。在这些函数内部,您可以设置和更改模板变量,即

$vars['styles']=drupal_get_css();

一旦完成,您就可以轻松地用一点逻辑交换 css 标签,此方法将允许您仅使用一个具有多个 css 文件的主题。 ..

I may be wrong but if you want to implement different themes on different pages, it sounds like what your looking for is "hook_custom_theme", it's pretty straight forward, basically you just add:

function mymodule_custom_theme(){
  //Some custom logic here
  $node=node_load(arg(1));
  if($node && $node->type=="my_custom_type"){
    return 'my_custom_theme';
  }
}

your return value must be a string that equals the machine readable name of the theme you're switching to...

re-reading your post, you may want to look into the template_preprocess_html and template_preprocess_page functions. Inside of these functions you can set and alter your template variables, i.e.

$vars['styles']=drupal_get_css();

once you've done that you could easily swap out css tags with a little bit of logic, this method would allow you to only use one theme with multiple css files....

落日海湾 2024-10-27 19:20:47

要激活子主题,您需要启用它并将其设置为默认值。

子主题(或任何与此相关的主题)适用于整个网站。要主题化单个页面,您可以为该特定页面创建一个模板,或者使用面板模块 - 有很多方法可以在 drupal 中给猫换皮......

这里有一些更多信息 Drupal 7 主题系统更改

to activate a subtheme, you need to enable it and set it as default.

The subtheme (or any theme for that matter) is for the site as a whole. To theme an individual page you could create a template for that specific page, or use the Panels module - there are many ways to skin a cat in drupal.....

here is some more info Drupal 7 theme system changes

面犯桃花 2024-10-27 19:20:47

通过使用themekey模块,你可以实现这个

参考http://drupal.org/project/themekey

By using themekey module you can achieve this

Refer http://drupal.org/project/themekey

清眉祭 2024-10-27 19:20:47

要在站点范围内激活您的主题并用作所有页面的默认主题,您需要进入管理/外观并激活您的主题,然后单击主题“定义为默认”旁边的链接。

要在一个特定页面上使用您的主题,这会有点棘手,只需澄清这是否是您真正想要的。

To have your theme activated site-wide and used as default for ALL pages, you need to go in admin/appearance and activate your theme, and then click on the link beside the theme "Define as default".

To have your theme used on one specific page, that would be a bit trickier to do, just clarify if that is what you really wanted.

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