[英]Drupal 7 Views - loop into $fields and get the content
So far, I have done the following things. 到目前为止,我已经做了以下事情。
1 - created a view i called it (vue-du-galerie) with three fields (field_galerie_image,field__galerie_description,title) 1-创建了一个名为我的视图(vue-du-galerie),该视图具有三个字段(field_galerie_image,field__galerie_description,title)
2 - Created a custom theme as 'views-view-fields--vue-du-galerie.tpl.php' 2-创建了一个自定义主题为“ views-view-fields--vue-du-galerie.tpl.php”
3 - The block is working without a problem. 3-块正在正常运行。
the html markup of the three fields : 三个字段的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>
i tried this code in views-view-fields--vue-du-galerie.tpl.php but it it"s not working : 我在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>
Maybe $field['YOUR_FIELD']->content
is printing fields data with the extra markup added by views module. 也许
$field['YOUR_FIELD']->content
正在打印包含视图模块添加的额外标记的字段数据。
If that is the case, make sure that your view is printing only the field markup without any wrapper elements. 如果是这种情况,请确保您的视图仅打印字段标记,而没有任何包装元素。 From your view administration page
admin/structure/views/view/VIEW_ID
loop through all your fields. 从您的视图管理页面
admin/structure/views/view/VIEW_ID
遍历所有字段。
From Style settings
; 从
Style settings
; check Customize field HTML
and Customize field and label wrapper HTML
, and change the value of HTML element
to - None -
. 检查
Customize field HTML
和Customize field and label wrapper HTML
,和值更改HTML element
来- None -
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.