Drupal - dynamically add class to wrapping div bas

2019-09-06 10:03发布

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条回答
Fickle 薄情
2楼-- · 2019-09-06 10:50

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.

查看更多
登录 后发表回答