0

在我的自定义theme-settings.php(zen-subtheme)中,我输入了以下代码以在我的主题设置中获取一个带有textformat的新textarea:

  <?php
    function paper_form_system_theme_settings_alter(&$form, &$form_state)  {
        $form['paper_data'] = array(
        '#type' => 'text_format',
        '#title' => 'Put Text in here:',
        '#rows' => 5,
        '#resizable' => FALSE,
        '#default_value' => 'xyz..',
        '#format' => 'full_html'
      );
    }

表格工作得很好,但是当我想通过写来访问变量时

<?php
$pdata = theme_get_setting('paper_data');
echo $pdata;
?>

在我的 page.tpl.php 中,变量的内容没有被渲染——而是打印了“Array”这个词......出了什么问题,为什么?(如果我使用 'textarea' 作为类型而不是 'text_format',一切都会很好地呈现。)

4

1 回答 1

0

You will understand when you use something like the Devel module's dpm() function to check the variable rather than echo(). Coding Drupal without the Devel module is, IMHO, folly.

The issue very likely stems from your use of the text_format type. As you can see, it saves both the textarea value as well as an associated text format. When this is used Drupal returns the data in structured form which varies depending on the type of format.

dpm() is your friend :)

于 2012-01-06T16:11:29.127 回答