N
N
Nikolai Kolesnichenko2015-07-26 16:03:58
Drupal
Nikolai Kolesnichenko, 2015-07-26 16:03:58

How to display $view->result?

It is necessary to programmatically display one field from views in the Calendar module template.
print_r($view->result) gives the following:

Array
(
    [0] => stdClass Object
        (
            [field_data_event_calendar_date_delta] => 0
            [date_id_event_calendar_date] => 9
            [date_delta_event_calendar_date] => 0
            [node_title] => 2015-07-28 00:00:00
            [nid] => 9
            [field_data_event_calendar_date_event_calendar_date_value] => 2015-07-28 00:00:00
            [field_data_event_calendar_date_node_entity_type] => node
            [_field_data] => Array
                (
                    [nid] => Array
                        (
                            [entity_type] => node
                            [entity] => stdClass Object
                                (
                                    [vid] => 9
                                    [uid] => 1
                                    [title] => 2015-07-28 00:00:00
                                    [log] => 
                                    [status] => 1
                                    [comment] => 1
                                    [promote] => 0
                                    [sticky] => 0
                                    [nid] => 9
                                    [type] => event_calendar
                                    [language] => ru
                                    [created] => 1437909391
                                    [changed] => 1437909391
                                    [tnid] => 0
                                    [translate] => 0
                                    [revision_timestamp] => 1437909391
                                    [revision_uid] => 1
                                    [event_calendar_status] => Array
                                        (
                                            [und] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [tid] => 7
                                                        )

                                                )

                                        )

                                    [event_calendar_date] => Array
                                        (
                                            [und] => Array
                                                (
                                                    [0] => Array
                                                        (
                                                            [value] => 2015-07-28 00:00:00
                                                            [timezone] => Europe/Moscow
                                                            [timezone_db] => Europe/Moscow
                                                            [date_type] => datetime
                                                        )

                                                )

                                        )

                                    [rdf_mapping] => Array
                                        (
                                            [rdftype] => Array
                                                (
                                                    [0] => sioc:Item
                                                    [1] => foaf:Document
                                                )

                                            [title] => Array
                                                (
                                                    [predicates] => Array
                                                        (
                                                            [0] => dc:title
                                                        )

                                                )

                                            [created] => Array
                                                (
                                                    [predicates] => Array
                                                        (
                                                            [0] => dc:date
                                                            [1] => dc:created
                                                        )

                                                    [datatype] => xsd:dateTime
                                                    [callback] => date_iso8601
                                                )

                                            [changed] => Array
                                                (
                                                    [predicates] => Array
                                                        (
                                                            [0] => dc:modified
                                                        )

                                                    [datatype] => xsd:dateTime
                                                    [callback] => date_iso8601
                                                )

                                            [body] => Array
                                                (
                                                    [predicates] => Array
                                                        (
                                                            [0] => content:encoded
                                                        )

                                                )

                                            [uid] => Array
                                                (
                                                    [predicates] => Array
                                                        (
                                                            [0] => sioc:has_creator
                                                        )

                                                    [type] => rel
                                                )

                                            [name] => Array
                                                (
                                                    [predicates] => Array
                                                        (
                                                            [0] => foaf:name
                                                        )

                                                )

                                            [comment_count] => Array
                                                (
                                                    [predicates] => Array
                                                        (
                                                            [0] => sioc:num_replies
                                                        )

                                                    [datatype] => xsd:integer
                                                )

                                            [last_activity] => Array
                                                (
                                                    [predicates] => Array
                                                        (
                                                            [0] => sioc:last_activity_date
                                                        )

                                                    [datatype] => xsd:dateTime
                                                    [callback] => date_iso8601
                                                )

                                        )

                                    [cid] => 0
                                    [last_comment_timestamp] => 1437909391
                                    [last_comment_name] => 
                                    [last_comment_uid] => 1
                                    [comment_count] => 0
                                    [name] => admin
                                    [picture] => 0
                                    [data] => b:0;
                                )

                        )

                )

            [field_event_calendar_date] => Array
                (
                    [0] => Array
                        (
                            [rendered] => Array
                                (
                                    [#markup] =&gt; <span class="date-display-single" property="dc:date" datatype="xsd:dateTime" content="2015-07-28T00:00:00+03:00">вторник, июля 28, 2015</span>
                                    [#access] =&gt; 1
                                )

                            [raw] =&gt; Array
                                (
                                    [value] =&gt; 2015-07-28 00:00:00
                                    [timezone] =&gt; Europe/Moscow
                                    [timezone_db] =&gt; Europe/Moscow
                                    [date_type] =&gt; datetime
                                )

                        )

                )

        )

)

How to get event_calendar_status?
Tried like this:
<?php print $view->result[0][_field_data][nid][entity][event_calendar_status][und][0][tid];   ?>

I get:
Cannot use object of type stdClass as array in

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
afi13, 2015-07-27
@Negatiff

You are accessing object properties like arrays.

$view->result[0]->_field_data['nid']['entity']->event_calendar_status[LANGUAGE_NONE][0]['tid'];

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question