0

i wondering how i can hide $title if its on the front page and on taxonomy pages, I only want it to show on nodes.

here my code, I dont know if im close or not =)

function bartik_process_html($variables){
    if(!drupal_is_taxonomy()){
    $variables['title']['class'][] = 'element invisible';
    }
    elseif(!drupal_is_front_page()){
    $variables['title']['class'][] = 'element invisible';
    }
    else{

    }
}

3 Answers 3

1

Just a few notes from what you have so far:

  • I agree with Dave Hall, create a subtheme instead of hacking on Bartik in core
  • Your logic is backwards, you would be looking for if (drupal_is_front_page()) {... instead of if (!drupal_is_front_page()) {...
  • There is no function drupal_is_taxonomy() (unless you created it)
  • The core style is element-invisible instead of two separate classes element invisible (again unless you created these classes separately)

A really easy way to remove these titles is to create simple template files and remove the code that prints the title. For instance, using the code from Bartik's page.tpl.php, copy all the code and create 2 files: page--front.tpl.php and page--taxonomy--term.tpl.php. Inside those files you can remove

<?php print render($title_prefix); ?>
<?php if ($title): ?>
   <h1 class="title" id="page-title">
      <?php print $title; ?>
   </h1>
<?php endif; ?>
<?php print render($title_suffix); ?>

Save the files to your theme, and clear the cache.

2

Try something like this:

<?php
   function hook_preprocess_page(&$variables) {
       if (drupal_is_front_page() || drupal_is_taxonomy()) {
           $variables['title'] = NULL;
       }
   }

Change hook to the name of your theme. Based on your example, it looks like you're hacking core which isn't good. Create a subtheme and implement your custom themeing there.

1
  • nope didnt work Commented Sep 13, 2011 at 23:10
1

You can also do it using CSS using classes on the body tag like this :

.front .title {
    display: none;
}
1
  • Trust me if I simply wanted a display none I would do it... Commented Sep 13, 2011 at 23:16

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.