Drupal - dynamically add class to wrapping div based on panel pane content node type

你。 提交于 2019-12-25 07:21:27

问题


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'].


回答1:


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.



来源:https://stackoverflow.com/questions/18114853/drupal-dynamically-add-class-to-wrapping-div-based-on-panel-pane-content-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!