如何为Drupal中视图生成的链接标签添加标题属性?
我使用 Drupal 中的视图模块构建了一个视图,以显示缩略图网格 (field_image),这些缩略图链接到全尺寸图像以与 Lightbox 一起使用。
我已经使该部分正常工作,但我还在缩略图下方显示标题文本。我想将此标题文本附加到 A 标记,例如: ...
I考虑过覆盖 views-view-field.tpl.php
模板,但这不是该模板中的 HTML,它只是打印 $output;
我假设视图模块中某处的某些 PHP 函数正在为链接生成实际的 HTML 代码,但我不知道在哪里以及如何在我的主题中覆盖它。
任何帮助将不胜感激。
I've built a view using the views module in Drupal to display a grid of thumbnail images (field_image) that are linked to a full size image for use with Lightbox.
I've got that part working but I also display caption text beneath the thumbnail image. I want to append this caption text to the A tag like: <a href="image/photo.jpg" title="My Image Caption">...</a>
I looked at overriding the views-view-field.tpl.php
template but this is no HTML in this template it just prints $output;
I'm assuming that some PHP function somewhere in the views module is generating the actual HTML code for the link but I don't know where and how to override it in my theme.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
views-view-field.tpl.php
的 $output 是在视图字段处理程序本身中默认生成的。您可以保留 $output 变量,并使用文件开头注释中提到的模板变量来构建您自己的输出。我安装 devel 模块,然后使用 dpm($row) (等)查看可用的值。您的视图拉动的所有字段都在模板中可用。这包括您选中“排除”选项的字段。
在构建链接时,我建议您使用 Drupal API 函数,这样链接将被其他 Drupal 函数正确修改。
The $output for
views-view-field.tpl.php
is generated by default in the views field handler itself. You can set aside the $output variable, and use the template variables mentioned in the comments at the start of the file to build your own output.I install the devel module, then using
dpm($row)
(etc) to see what values are available. All fields your View is pulling are available in the template. This includes fields for which you check on the "Exclude" option.In building your link, I suggest you use the Drupal API functions, that way the link will be properly modified by other Drupal functions.