简体   繁体   English

使用Customfield“ PHP代码”在视图中显示Drupal图像的附加路径

[英]Drupal Image attach path in view using Customfield “PHP code”

I created a View that gets the title, body and attached image of some Story nodes. 我创建了一个View,该View获取一些Story节点的标题,正文和附加的图像。 I need to use the Customfield "PHP code" to customize the output but the problem is that it's only giving me the id of the image in an array like this: [image_attach_iids] => Array ( [0] => 66 ). 我需要使用Customfield“ PHP代码”来自定义输出,但问题是它只给我这样的数组中图像的ID:[image_attach_iids] => Array([0] => 66)。 So, I it looks like it's giving me the id but I need the full path of the image also. 因此,我看起来像是给了我id,但我也需要图像的完整路径。 Is there some function that I need to call to get the path? 我需要调用一些函数来获取路径吗?

thank you 谢谢

  1. If you are using fields, you can put the image as a field. 如果使用字段,则可以将图像作为字段。 Put it at the top of your fields (so you can use replacement patterns). 将其放在字段顶部(以便您可以使用替换模式)。
    Setup: 设定:
    exclude from display, select 'path to image' in the Format option, and then use the replacement pattern in your customField PHP 从显示中排除,在“格式”选项中选择“图像路径”,然后在您的customField PHP中使用替换模式

  2. If you aren't using fields, you can build up the path in the node-[contenttype].tpl.php . 如果您不使用字段,则可以在node- [contenttype] .tpl.php中构建路径。

  3. Pathauto module: use the function drupal_get_path_alias($path) to get the aliased path to the node. drupal_get_path_alias($path)模块:使用函数drupal_get_path_alias($path)获取节点的别名路径。 $path = 'node/'.$node_id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM