开发者

drupal views---how to output it

开发者 https://www.devze.com 2023-01-28 18:25 出处:网络
the print_r($a)\'s result is views_handle_field_node Object ( [view]=>view Object ( [db_table] => views_view

the print_r($a)'s result is

views_handle_field_node Object

    (

    [view]=>view Object

   (
 [db_table] => views_view
 [base_table] => node
 [args] => Array
    (
        [0] => My entry 1
    )

[use_ajax] =>
[result] => Array
    (
        [0] => stdClass Object
            (
                [nid] => 5
                [node_title] => Title of a test entry
                [node_revisions_body] =>
                [node_revisions_format] => 1
                [node_vid] => 5
                [term_data_name] => My first test term name
                [term_data_vid] => 1
                [term_data_tid] => 1
                [vocabulary_name] => Vocabulary 1
                [node_revisions_vid] => 5
            )

        [1]=> stdClass Object
              (
                 [nid] => 8
                [node_title] => Title of a test entry
                [node_revisions_body] =>
                [node_revisions_format] => 1
                [node_vid] => 5
                [term_data_name] => My first test term name
                [term_data_vid] => 1
                [term_data_tid] => 1
                [vocabulary_name] => Vocabulary 1
                [node_revisions_vid] => 5
        ..
        [2]..
         ..

how to us开发者_JAVA百科e one variable's name to out put the [nid]=>5 and[nid]=>8.....and all the nid.i use this, but can't work.

$views_handle_field_node->$view->$result[]->nid


The variables name is $a not `$views_handle_field_node' so try:

$first = $a->view->result[0]->nid;

//access all of the results?
foreach ($a->view->result as $obj) {
    //do something with $obj->nid;
}

If that doesn't help then tell us what is the context? Are you putting this code inside a module hook or a template file? I that case what type of view settings. Tell us the "Style" and "Row style".


$first = $views_handle_field_node->view->result[0]->nid;

//access all of the results?
foreach ($views_handle_field_node->view->result as $obj) {
    //do something with $obj->nid;
}
0

精彩评论

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