覆盖 drupal 日历主题
我正在尝试为日历视图设置主题,有没有办法用模块覆盖主题路径而不是覆盖模板文件?
我想创建一个覆盖主题功能的模块,以便我可以在模块中包含模板文件而不是日历模块。
提前谢谢
I am trying to theme a calendar view, is there a way to override the theming path with a module instead of overwriting the template files?
I want to create a module that overrides the theming functions so I can include the template files in my module instead of the calendar module.
thx in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以覆盖模块中的视图模板,请参阅 在模块中使用默认视图视图高级帮助页面。由于日历是一个视图插件,我认为视图模板的基本行为适用。如果在
hook_theme($existing, $type, $ theme, $path)
不适用于日历视图,您可能需要使用hook_theme_registry_alter(&$items)
。You can override views template in a module, see the "Theming your views in your module" in the Using default views in your module page of Views' Advanced Help. Since Calendar is a views plugin, I think the basic behaviors of Views templating applies. If declaring your own themeable output in your
hook_theme($existing, $type, $theme, $path)
doesn't work for a Calendar view, you may need to usehook_theme_registry_alter(&$items)
.我认为你不能在模块中做类似的事情,至少不能以干净的方式做。
Drupal 将功能(模块)和表示(主题)分开。将两者分开是很有意义的。
因此如果您可以在模块中执行类似的操作,我不会感到惊讶。但你会在 Drupal 的支持下工作,并且很难做到这一点,而且没有充分的理由。
如果您想创建可重用的样式、模板覆盖等,请改用子主题系统。
I don't think you can do something like that in a module, at least not in a clean way.
Drupal have functionality (modules) and presentation (themes) separated. It makes good sense to divide the two.
So I wouldn't be surprised if you could do something like this in a module. But you would be working against Drupal, have a hard time doing it, and with no good reason.
If you want to create reusable styles, template overrides etc, use the sub theme system instead.
看来您在这里要做的是重写
calendar
模块的功能,在主题层有机会干预它之前完全取代正常的日历行为。在这些(希望很少见)情况下,最好的办法是创建您自己的
calendar
分支作为新模块,并以现有calendar
代码作为起点。直接修改模块代码比尝试破解 Drupal 的基本功能/显示交互要容易得多。我通常不会推荐这样做,但它似乎适合您的情况。
请务必将任何改进发送回日历开发人员,以便我们都能受益:)
It seems like what you're looking to do here is rewrite how the
calendar
module functions, in a way that completely replaces normal calendar behavior before the theme layer has a chance to meddle with it.In these (hopefully rare) cases, the best thing to do is create your own fork of
calendar
as a new module, with the existingcalendar
code as a starting point. Modifying the module code directly will be much easier than trying to hack Drupal's basic functionality/display interactions.I normally wouldn't recommend this, but it seems appropriate in your case.
Be sure to send any improvements back to the calendar devs so that we all can benefit :)