0

I am creating a template for my table style view. I have several fields most of which are excluded from display. Inside my template I want to print those excluded from display fields. After some search I found that you can access all fields including those excluded by using:

$view->result[$row_count]->

Now the field I want to print is a file. This is the structure that dpm returns me:

field_field_programme (Array, 1 element)

0 (Array, 2 elements)
    rendered (Array, 3 elements)
        #theme (String, 9 characters ) file_link
        #file (Object) stdClass
            fid (String, 4 characters ) 1011
            display (String, 1 characters ) 1
            description (String, 0 characters )
            uid (String, 1 characters ) 1
            filename (String, 10 characters ) seminar3.pdf
            uri (String, 40 characters ) public://seminaria/programmes/seminar3.pdf
            filemime (String, 15 characters ) application/pdf
            filesize (String, 6 characters ) 218882
            status (String, 1 characters ) 1
            timestamp (String, 10 characters ) 1333973478
            rdf_mapping (Array, 0 elements)
        #access (Boolean) TRUE
    raw (Array, 11 elements)
        fid (String, 4 characters ) 1011
        display (String, 1 characters ) 1
        description (String, 0 characters )
        uid (String, 1 characters ) 1
        filename (String, 10 characters ) seminar3.pdf
        uri (String, 40 characters ) public://seminaria/programmes/seminar3.pdf
        filemime (String, 15 characters ) application/pdf
        filesize (String, 6 characters ) 218882
        status (String, 1 characters ) 1
        timestamp (String, 10 characters ) 1333973478
        rdf_mapping (Array, 0 elements)

It is not as simple as using $field->content. How can I print my file? Do I need to create a link and add the information above? What code can I use so depending on the filemime the icon will change?

In other views I have created the output of files is:

<a type="xxx; length=xxx" href="xxx"><img src="/modules/file/icons/xxx" title="xxx" alt="" class="file-icon"></a>

With the information I get from the file I could create such a link. I am guessing length is the filesize? Maybe there is an api function that constructs file links?

0

Using this seems to do exactly what I want

<?php print $view->style_plugin->rendered_fields[$row_count]['field_programme']; ?>

which is extremely useful since it can be used even for fields that have been excluded from the display of the view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.