开发者

if ($node->type == 'x') not working in theme_upload_attachments function

I want the header for the uploaded files to display a different text depending on the node type. I overrided the core function copying it into my theme's template.php file and renamed it to phptemplate_upload_attachments.

<?php
    function phptemplate_upload_attachments($files) {
        global $node;
        $header = array(t('Default text'), t('Size'));

        if ($node->type == 'orange') {
            $header = array(t('ORANGE CUSTOM TEXT'), t('Size'));
        }


        $rows = array();
        foreach($files as $file) {
            $file = (object)$file;
            if ($file->list && empty($file->remove)) {
                $href = file_create_url($file->filepath);
                $text = $file->description ? $file->description : $file->filename;
     开发者_如何学运维           $rows[] = array(l($text, $href), format_size($file->filesize));
            }
        }
        if (count($rows)) {
            return theme('table', $header, $rows, array('id' => 'attachments'));
        }
    }
?>

As you can guess, I only added the line for the orange node type, but it does not work. I know the function is correctly overidden because I tested it changing the default text. Also, I cleared the cache, and i tried adding global $node.

Why is this not working?


Is $node available? Try this:

$node = node_load(arg(1));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜