i would like to hide the post information for my content type, but programmatically.

I don't find where the author and date information is stocked in the database, and I would like to hide it.

How can I achieve this?


i find....

variable_set('node_submitted_'.$my_content_type, false);
| improve this answer | |
  • hi wall-e please consider the solution as said by Bustikiller – vishwa Nov 17 '15 at 12:55
  • If prefer this solution to the one posted by Bustikiller. Using the node.tpl.phjp template means that you either hide the information for all content types, or that you will use different node templates per content type, just to hide the information. Leading to lots of duplicated code (bad for maintenance). – Pierre Buyle Dec 4 '15 at 14:09

You can use an implementation of hook_preprocess_HOOK() to set $display_submitted variables used in (good practices following) node templates to control whether or not to display the information.

function XYZ_preprocess_node() {
  $node = $variables['node'];
  $variables['display_submitted'] &= ($node->type != 'content-type')

Where XYZ is the name of a custon module or theme, andcontent-type is the machine name of the content you want to hide the publishing information for.

| improve this answer | |
  • This is preferable to altering the template theme. – kiamlaluno Dec 9 '15 at 10:22

Try deleting the following lines in your theme node.tpl.php template:

<?php if ($display_submitted): ?>
    <div class="meta submitted">
      <?php print $user_picture; ?>
      <?php print $submitted; ?>
<?php endif; ?>
| improve this answer | |
  • It would be much preferable to use a different template file for that content type, instead of altering the template file used for every node. Also, this solution is not something that can be done programmatically. – kiamlaluno Dec 9 '15 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy