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

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

问题描述

我正在使用drupal 7面板到处模块,我已经为我的主页设置了一个面板页面模板。问题是我需要在模板中的一个包装div中添加一个类,它依赖于包装器内的面板窗格中的节点类型。这需要动态添加,因为我们的网站编辑器将会大量移动面板窗格。



我的模板中的一行显示如下:

 < 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屋!

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