【问题标题】:Drupal 7 Views - loop into $fields and get the contentDrupal 7 Views - 循环到 $fields 并获取内容
【发布时间】:2013-08-27 03:22:56
【问题描述】:

到目前为止,我做了以下事情。

1 - 创建了一个我称之为 (vue-du-galerie) 的视图,其中包含三个字段 (field_galerie_image,field__galerie_description,title)

2 - 创建了一个自定义主题为“views-view-fields--vue-du-galerie.tpl.php”

3 - 块工作没有问题。

三个字段的html标记:

        <div class="content-block-contact content-block-gallerie">
            <section class="slider">
                <div id="slider" class="flexslider">
                    <ul class="slides">
                    <!--(from here)loop between all the image fields -->
                        <li>
                            <img src="images/6.png" /> <!--field_galerie_image-->
                        </li>
                        <li>
                            <img src="images/6.png" /> <!--field_galerie_image-->
                        </li>
                        <li>
                            <img src="images/6.png" /><!--field_galerie_image-->
                        </li>
                    <!--(to here)-->
                    </ul>
                </div>
                <div id="carousel" class="flexslider">
                    <ul class="slides">
                    <!--(from here)loop between all the fields and make them like this -->
                        <li>
                            <div class="field-image-gallerie"><img src="images/6.png" /><!--field_galerie_image--></div>
                            <div class="field-titre-gallerie"><h1>Thématique 1<!--title--></h1></div>
                            <div class="field-description-gallerie"><p>Lorem upsom dolor i,setLorem Lorem upsom dolor i,set <!--field__galerie_descriptiont-->n</p></div>
                        </li>
                        <li>
                            <div class="field-image-gallerie"><img src="images/6.png" /><!--field_galerie_image--></div>
                            <div class="field-titre-gallerie"><h1>Thématique 1<!--title--></h1></div>
                            <div class="field-description-gallerie"><p>Lorem upsom dolor i,setLorem Lorem upsom dolor i,se <!--field__galerie_descriptiont--></p></div>
                        </li>
                    <!--(to here)-->
                    </ul>
                </div>
            </section>
        </div>

我在 views-view-fields--vue-du-galerie.tpl.php 中尝试了这段代码,但它不起作用:

<div id="slider" class="flexslider">
    <ul class="slides">
        <?php foreach ($fields as $id => $field): ?>
            <li>
                <?php print $field['field_galerie_image']->content; ?>
            </li>
        <?php endforeach; ?>
    </ul>
</div>

<div id="carousel" class="flexslider">
    <ul class="slides">
        <?php foreach ($fields as $id => $field): ?>
            <li>
                <div class="field-image-gallerie"><?php print $field['field_galerie_image']->content; ?></div>
                <div class="field-titre-gallerie"><h1><?php print $title; ?></h1></div>
                <div class="field-description-gallerie"><p><?php print $field['field__galerie_description']->content; ?></p></div>
            </li>
        <?php endforeach; ?>
    </ul>
</div>

【问题讨论】:

    标签: php drupal drupal-7 drupal-views drupal-theming


    【解决方案1】:

    也许$field['YOUR_FIELD']-&gt;content 正在打印带有视图模块添加的额外标记的字段数据。

    如果是这种情况,请确保您的视图只打印没有任何包装元素的字段标记。从您的视图管理页面admin/structure/views/view/VIEW_ID 循环浏览您的所有字段。

    来自Style settings;检查Customize field HTMLCustomize field and label wrapper HTML,将HTML element的值改为- None -

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-22
      • 1970-01-01
      • 1970-01-01
      • 2014-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多