0

I have a News page which links to a bunch of news articles and I'm looking to print the header of the News Page on the individual articles.

The field_get_items doesn't return anything right now. Any advice would be greatly appreciated!

if ($node->type == 'article') {
         $news_header = field_get_items('page', $node, 'group_header'); print_r($news_header);

             //$url = file_create_url($node->field_header_image['und'][0]['uri']);
             //echo '<img src="' . $url . '" width="100%">';   
            // }
        }

1 Answer 1

1

Are you loading the node first? If you are not getting anything returned then it's probably because $node isn't set. Also is the 'News node' a node type of article?

I would start by trying to retrieve the node information first:

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

Also I think your field_get_items is not working as your entity type is 'page' but you are inside a check for a node type of article try:

$news_header = field_get_items('node', $node, 'group_header'); 
4
  • This is retrieving the information of the current node that I'm in which is an article content type. I need to retrieve a field - group_header from a different node which is content type page = news. thanks for you help on this!
    – MG1
    Mar 10, 2016 at 15:22
  • 1
    Ok that makes sense does the article have the news page as a menu parent? Or is it in the irk path? Mar 10, 2016 at 21:05
  • Here's an example of an article path: news/2015/12/09/article-name. news is page that lists all the news articles.
    – MG1
    Mar 11, 2016 at 1:50
  • 1
    It looks like you have no way of loading that node information while on the article, The easiest answer is to make a block as a header image for the articles. What is the path of the hub page you want the header from? if it's 'news' you could work with that. Mar 11, 2016 at 18:15

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.