【问题标题】:From custom formatters to a field?从自定义格式化程序到字段?
【发布时间】:2010-08-23 16:30:37
【问题描述】:

我使用自定义格式化程序(Drupal、CCK)创建了一个字段。
现在我得到了这个 PHP 代码来导出

/**
* Implements hook_theme().
*/
function product_attribute_theme() {
  return array(
    'product_attribute_formatter_product_attribute' => array(
      'arguments' => array('element' => NULL),
    ),
  );
}

/**
* Implements hook_field_formatter_info().
*/
function product_attribute_field_formatter_info() {
  return array(
    'product_attribute' => array(
      'label' => 'Product Attribute',
      'description' => t('an Attribute of a Product'),
      'field types' => array('content_taxonomy', 'text'),
      'multiple values' => CONTENT_HANDLE_MODULE,
    ),
  );
}

function theme_product_attribute_formatter_product_attribute($element) {
  return ($element['#item']['value']);
}

我尝试将其添加为 CCK 中的模块,但它没有将其添加到字段中,我该怎么做?

【问题讨论】:

    标签: drupal cck custom-formatting


    【解决方案1】:

    您创建和导出的格式化程序仍需要选择为特定字段的活动格式化程序,您可以在不导出格式化程序的情况下执行此操作。

    要做到这一点,这实际上取决于您想要格式化的位置和内容,但通常这可能是节点显示上的 CCK 字段,可以在内容类型“显示字段”页面上设置:@987654321 @

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-15
      • 2016-11-30
      • 2023-02-08
      相关资源
      最近更新 更多