0

What I want to do is remove the title of a specific content type from where it normally shows throughout the site and print it somewhere else in the template.

I have a custom node.tpl.php for the content type, lets call it node--custom-content-type.tpl.php and it sits within a little submodule I made for this content type and section on the website. Let's call that mycustom_subtheme. I have also created a custom page.tpl.php, page--custom-content-type.php.

I was able to successfully re-print the title later on in the template, thanks to Aram's explanation here, by putting <?php print $title; ?> after <?php print render($content); ?>. I'm looking to find a way to remove it from it's original section just for this content type; See screenshot below.

Things I've tried:

  • I tried the Exclude Node Title module, but as I feared, it actually renders the title null, which isn't suitable for my purpose of retaining the title but just moving it. For this reason, this post isn't what I need.

  • I tried hide($content['title']); and hide($title); just to see if that would work in node--custom-content-type.tpl.php.

  • I tried moving the $title data to something like $title2 and then replacing $title with "Custom Text" but am not sophisticated enough to pull that off.

  • I tried adding custom CSS to no avail (the title is H2 in my node template): body.node-type-custom-content-type h2.title, {display: none;}

  • And finally, I even tried all the suggestions here. At the very least, copying the page.tpl.php and removing the title should have worked.

Here is a pastebin of my codes: custom node template and custom page template

Does the original node.tpl.php inherit the title anyway if node--custom-content-type.tpl.php simply doesn't mention it?

enter image description here

3
  • 1
    what if you delete everything inside of node--mycontenttype.tpl.php, does it still show up?
    – No Sssweat
    Commented Aug 15, 2017 at 9:01
  • What about node.tpl.php filling in the title anyway If node--mycontenttype.tpl.php exists for that content type, then node.tpl.php never gets loaded, so this can't be it.
    – No Sssweat
    Commented Aug 15, 2017 at 9:02
  • Still shows up.
    – Christia
    Commented Aug 18, 2017 at 22:39

1 Answer 1

0

I managed to get this to work but welcome better options. I prefer not to alter the theme, but rather use a function or something else instead so that this module can stand alone and not be affected by themes and subthemes and other design team changes.

Here's what I did:

body.node-type-answers-question .page-title {
  visibility:hidden;
}

The source code of the loaded page, which is from a node content type called answers-question. I noticed that there was a "page-title" class in the h1 title. Making the visibility hidden worked for me.

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.