Drupal - 根据面板窗格内容节点类型动态地将类添加到包装 div [英] Drupal - dynamically add class to wrapping div based on panel pane content node type

查看:20
本文介绍了Drupal - 根据面板窗格内容节点类型动态地将类添加到包装 div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 drupal 7 面板无处不在模块,并且我已经为我的主页设置了面板页面模板.问题是我需要向模板中的包装 div 添加一个类,该类取决于包装器内的面板窗格内的节点类型.这需要动态添加,因为我们的站点编辑器会经常移动面板窗格.

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>

我想根据 $content['content-row1'] 中的节点类型在 'content_wrapper' div 上动态添加一个类.

And I want to dynamically add a class on the 'content_wrapper' div dependant on the node type inside $content['content-row1'].

推荐答案

从面板模块中找到打印该面板布局的 tpl.php 文件(可以在panels/plugins/layouts/YOUR_LAYOUT"文件夹)并将其复制到您的主题文件夹中.

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.

在 tpl.php 文件中添加 php 代码,方法与编辑 drupal 主题相同.

In the tpl.php file add the php code the same way you edit drupal themes.

这篇关于Drupal - 根据面板窗格内容节点类型动态地将类添加到包装 div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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