【问题标题】:How can I list Content Types as checkbox in Profile types for Drupal如何在 Drupal 的配置文件类型中将内容类型列为复选框
【发布时间】:2014-11-14 01:26:04
【问题描述】:

在drupal用户注册中,用户应该能够选择他们想要订阅的类型。那么,如何在自定义配置文件注册类型中列出内容类型(节点类型)?

http://i.stack.imgur.com/hvWd2.png

【问题讨论】:

    标签: drupal drupal-7 drupal-content-types


    【解决方案1】:

    您可以使用node_type_get_names() 函数检索所有内容类型。 所以,在 hook_form_alter 添加:

    $form['ct'] = array(
      '#type' => 'checkboxes',
      '#options' => node_type_get_names(),
      '#title' => t('What standardized tests did you take?'),
    );
    

    【讨论】:

    • 你太棒了,效果很好。如何在列出时跳过第一个内容类型?
    • 你最好不要跳过它,而是取消设置一个不需要的:$options = node_type_get_names();未设置($options['article']);其中“文章”是您要删除的内容类型。
    • 还有一个问题:如何将这些(选中的复选框)值插入到表格中并在将来读取? stackoverflow.com/questions/26039974/…
    猜你喜欢
    • 2013-02-08
    • 1970-01-01
    • 2012-07-04
    • 2013-11-20
    • 2013-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多