I need to render a limited number of fields from a given content type, without exposing the new ones I may add some day in the future.

Now I have:

print render($page)

When a new field is added to the content type, I have that added to the render($page) as well. I don't want this to happen. Aside hiding the field from "admin/structure/types/manage/CONTENT_TYPE/display", how can I programmatically exclude new fields from render.


A common way is to use hide() function in a preprocess hook as:

  • I don't know the field name I will add tomorrow – augusto Mar 14 '18 at 14:08

What you could do is not render out all of $page. So you could get rid of:

print render($page)

And instead just render the elements within it you want e.g. :

print render($page['field_my_field']);

That will mean no matter what other fields you add in the future only the ones you specifically render in your template will be shown

  • This would imply a parcial CSS rewrite, already tested. – augusto Mar 14 '18 at 20:35

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.