drupal视图:如何为emfields调用swftools媒体播放器?

发布于 2024-11-03 02:35:09 字数 899 浏览 1 评论 0原文

我正在使用 swftools 来显示文件字段(Drupal 6)。
现在我想使用 swftools 显示自定义 url emfields (嵌入媒体字段)。例如,如果我的 emaudio 字段包含 URL http://example.com/myaudio.mp3。我想使用 swftools 音频播放器来播放这个 mp3 文件。

如果我显示包含 emfield 的节点,我知道如何调用 swftools 播放器。我使用 hook_preprocess_content_field() 将 $items[0]['view'] 替换为 swf($items[0]['value']):

function mytheme_preprocess_content_field(&$vars) {
  foreach ($vars['items']as $index=>$arr){
    // Note: 
    // Emfield's custom_url video provider is called "zzz_custom_url".
    // Emfield's custom_url audio provider is called "custom_url"
    if ($arr['provider']=='zzz_custom_url' || $arr['provider']=='custom_url'){
      $vars['items'][$index]['view'] = swf($arr['value']);
    }
  }
}

但如果我显示 view 包含 emfield。也就是说,当我显示视图而不是节点时,我无法弄清楚如何实现类似的技巧。有什么建议吗?

I am using swftools to display filefields (Drupal 6).
Now I would like to use swftools to display the custom-url emfields (embedded media fields). For example, if my emaudio field contains the url http://example.com/myaudio.mp3. I would like to use the swftools audio player to play this mp3 file.

I know how to invoke the swftools player, if I am displaying a node that contains an emfield. I use hook_preprocess_content_field() to replace $items[0]['view'] with swf($items[0]['value']):

function mytheme_preprocess_content_field(&$vars) {
  foreach ($vars['items']as $index=>$arr){
    // Note: 
    // Emfield's custom_url video provider is called "zzz_custom_url".
    // Emfield's custom_url audio provider is called "custom_url"
    if ($arr['provider']=='zzz_custom_url' || $arr['provider']=='custom_url'){
      $vars['items'][$index]['view'] = swf($arr['value']);
    }
  }
}

But I do not know how to invoke the swf player if I am displaying a view that contains an emfield. That is, I have not been able to figure out how to pull off a similar trick when I am displaying a view rather than a node. Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

○闲身 2024-11-10 02:35:09

我有一个解决方案。
我创建了一个视图模板来主题我的 emaudio 字段,

views-view-field--field-my-emaudio-embed.tpl.php

这是模板的内容:

$data = $row->{$field->field_alias};
print swf($data);

I have a solution.
I created a views template to theme my emaudio field,

views-view-field--field-my-emaudio-embed.tpl.php

Here is the content of the template:

$data = $row->{$field->field_alias};
print swf($data);
∞梦里开花 2024-11-10 02:35:09

另一个解决方案:
创建自定义格式化程序“SWF Emaudio”,如下所述。然后选择此格式化程序以从 cck 或视图 UI 中显示您的自定义 url emaudio 字段。

function mymodule_field_formatter_info() {
  $formatters = array();
  $formatters['swf_emaudio'] = array(
      'label' => t('SWF Emaudio'),
  'field types' => array('emaudio'),
    );
}
function mymodule_theme() {
  $themes['mymodule_formatter_swf_emaudio'] = array(
      'arguments' => array('element' => NULL, 'options' => array()),
      'function' => 'theme_o4_mediatools_formatter_swf_emaudio',
    );
  }
  return ($themes);
}
function theme_mymodule_formatter_swf_emaudio($element, $options = array()) {
  $embed_value = $element['#item']['value'] ;
  $output = swf($embed_value, $options);
  return ($output);
}

Another solution:
Create the custom formatter "SWF Emaudio", as described below. Then select this formatter to display your custom-url emaudio field, from within the cck or views UI.

function mymodule_field_formatter_info() {
  $formatters = array();
  $formatters['swf_emaudio'] = array(
      'label' => t('SWF Emaudio'),
  'field types' => array('emaudio'),
    );
}
function mymodule_theme() {
  $themes['mymodule_formatter_swf_emaudio'] = array(
      'arguments' => array('element' => NULL, 'options' => array()),
      'function' => 'theme_o4_mediatools_formatter_swf_emaudio',
    );
  }
  return ($themes);
}
function theme_mymodule_formatter_swf_emaudio($element, $options = array()) {
  $embed_value = $element['#item']['value'] ;
  $output = swf($embed_value, $options);
  return ($output);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文