Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8568985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:13:50+00:00 2026-06-11T18:13:50+00:00

I have simple problem. I’ve a field in my content type (header image) that

  • 0

I have simple problem. I’ve a field in my content type (header image) that must be printed in page.tpl.php (because of layout).

It works fine, i put some code in theme_preprocess_page() function to show that field in page.tpl.php

function theme_preprocess_page( &$variables, $hook )
{
    $node = menu_get_object();

    if( $node && $node->type == 'page' )
    {
        $view = node_view($node);
        $variables['headerimage'] = render($view['field_headerimage']);
    }
}

Now i am having problem hiding that field_headerimage from node view. It cannot be hidden from administration ui (content types -> manage display) because if i hide it from there, it will not be available in theme_preprocess_page() either.

So i try to hide that field from preprocess_node

function theme_preprocess_node( &$variables, $hook )
{
    if( $variables['page'] )
    {
        hide($variables['field_headerimage']);
        unset($variables['field_headerimage']);
        $variables['field_headerimage'] = NULL;
    }
}

I added every line of code i’ve tried in removing that from being displayed. What am i doing wrong? Or: How do you hide field from theme_preprocess_node()

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:13:51+00:00Added an answer on June 11, 2026 at 6:13 pm

    In hook_preprocess_node() the content has already been built for the node object and dumped onto the content array; that’s the array that will be converted to $content in the template file, and the one you need to remove the field display from:

    if( $variables['page'] )
    {
        hide($variables['content']['field_headerimage']);
        // ...
    

    That should get rid of it no problem.

    For the sake of completeness you could also do this easily in the node.tpl.php file too:

    hide($content['field_headerimage']);
    

    Or in hook_node_view() in a custom module:

    function MYMODULE_node_view($node, $view_mode, $langcode) {
      hide($node->content['field_headerimage']);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple problem in php select option. The page has 5 select
I have a simple problem that I have not been able to find an
I have a simple problem that I've been stuck on for some time and
I have a simple problem that i cannot solve. I have a dictionary: aa
I have really simple problem in my PHP script. There is a function defined
I have a simple problem: I want to construct a regex that matches a
I have a simple problem: the WebGrid header doesn't change it's background color. Every
I have a simple problem that says: A password for xyz corporation is supposed
I have a simple problem in Python that is very very strange. def estExt(matriz,erro):
I have simple LINQ problem that I can't figure out. I have a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.