2

How can I add a checkbox when I create a new page to decide wheter the user want to display the node title or not, as like the hook_block_configure() function ?

2 Answers 2

0

To do this you need to follow the steps,

  1. Edit the Page content type and add a new field "Show Content title" and add this one as checkbox, boolean.
  2. In time of creating a new Page content check if you want to show the title or not.
  3. Set the Page Content Type's "Show Content title" as hidden in Manage Display Settings page.
  4. In your node.tpl.php you will see the following code

    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
    

    Then add some check over there,


    <?php if($content['field_show_title'] == 1) : ?>
    <h2<?php print $title_attributes; ?>>
    <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
    </h2>
    <?php endif; ?>

This can solve the issue.

0
1

There is now also this module: https://www.drupal.org/project/exclude_node_title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.