如何为Drupal中视图生成的链接标签添加标题属性?

发布于 2024-09-10 03:58:53 字数 390 浏览 12 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

放我走吧 2024-09-17 03:58:53

views-view-field.tpl.php 的 $output 是在视图字段处理程序本身中默认生成的。您可以保留 $output 变量,并使用文件开头注释中提到的模板变量来构建您自己的输出。

我安装 devel 模块,然后使用 dpm($row) (等)查看可用的值。您的视图拉动的所有字段都在模板中可用。这包括您选中“排除”选项的字段。

在构建链接时,我建议您使用 Drupal API 函数,这样链接将被其他 Drupal 函数正确修改。

l(t('Link Title'), url/path, array(
  'attributes' => array(
    'title' => t('My Image Caption'),
  ),
));

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.

l(t('Link Title'), url/path, array(
  'attributes' => array(
    'title' => t('My Image Caption'),
  ),
));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文