Drupal - 根据面板窗格内容节点类型动态添加类到包装div [英] Drupal - dynamically add class to wrapping div based on panel pane content node type
问题描述
我的模板中的一行显示如下:
< div class =content_wrapper>
< div id =main-content-row1class =content>
<?php print render($ content ['content-row1']); ?>
< / div>
< / div>
我想在'content_wrapper'div上动态添加一个类,取决于$内容['content-row1']。
找到从面板模块打印面板布局的tpl.php文件它可以在面板/插件/布局/ YOUR_LAYOUT 文件夹下找到),并将将其复制到您的主题文件夹中。
在tpl.php文件中添加与编辑drupal主题相同的PHP代码。
Am using the drupal 7 panels everywhere module and i have set up a panel page template for my homepage. Problem is I need to add a class to a wrapping div in the template that is dependant on the node type inside the panel pane which is inside the wrapper. This needs to be added dynamically as our site editors will be moving panel panes around a lot.
i.e. a row from my template looks like this:
<div class="content_wrapper">
<div id="main-content-row1" class="content">
<?php print render($content['content-row1']); ?>
</div>
</div>
And I want to dynamically add a class on the 'content_wrapper' div dependant on the node type inside $content['content-row1'].
Find the tpl.php file that prints that panel layout from the panels module (it can be found under "panels/plugins/layouts/YOUR_LAYOUT" folder) and copy it in your theme folder.
In the tpl.php file add the php code the same way you edit drupal themes.
这篇关于Drupal - 根据面板窗格内容节点类型动态添加类到包装div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!