Hello,
I'm using the blog module for blog posts and i cant figure out how to remove the "author's blog" that gets placed at the bottom of the blog next to the "read more..." and "add a new comment" links.

I've created a node-blog.tpl.php, and i know that <?php print $links; ?> is where the links get written to the page, and after searching all day i still cant figure out how to make sure the author's blog is NOT included.

thanks for any help!

Comments

fresh-off’s picture

am i on the right track to use a phptemplate_preprocess_node() function inside template.php?

i really dont know php too well - but here's as far as i've been able to get with trying to remove the blog_usernames_user (writes "author's blog" to the page) from my blog:

function phptemplate_preprocess_node(&$vars, $hook) {
  //try to remove blog_usernames_blog from links array
  $vars['links'] = unset($links[0]);
}

that throws the following error in template.php: Parse error: syntax error, unexpected T_UNSET
I dont really know what else to do next. am i on the right track? if so, how can i remove blog_usernames_blog from the links array?

I dont think i can upload images to Drupal.org, so the following link is a screenshot of the info i get using the Devel Module:
http://fresh-off.com/work/indigo/web-devel-screenshot.gif

dzepol’s picture

I am fairly new as well but I know this is something I'll be doing too. Although I won't be working on this for a few days (maybe this weekend)- I'll let you know if I find anything during my search.

fresh-off’s picture

On the Drupal Themes Mailing List, CK Ng over at http://fordrupal.com was nice enough to shoot me this code for removing the author's username from the blog! I still havent gotten it to work quite yet, but its farther than i would ever have gotten on my own!

I'm hoping some Drupal/PHP Ninja might be able to take a look at it and show me where the syntax error is. I placed it into template.php and get the following error:Parse error: syntax error, unexpected T_STRING. I cant seem to find it.

Perhaps I didnt quite understand his directions here:

/* duplicate theme_links() and add the 3rd line (marked with HERE) */
function phptemplate_links($links, $attributes = array('class' => 'links')) {
  $output = '';

  // HERE: just add this line, the rest are from theme_links() 
  unset($links['blog_usernames_blog']);

Here's the way I entered the code:

/* duplicate theme_links() and add the 3rd line (marked with HERE) */
function phptemplate_links($links, $attributes = array('class' => 'links')) {
  $output = 'unset($links['blog_usernames_blog'])';  //browser says syntax error is in this line...

  // HERE: just add this line, the rest are from theme_links() 
  //unset($links['blog_usernames_blog']);

I've looked through the snippet above, and the rest of the code (posted in its entirety below) and cant find the syntax error. I've tried messing about with single and double quotes, and some other stuff, but when i've gotten rid of the error, blog_usernames_blog still posts to the page.

Here's the code (in its entirety) that CK Ng sent me:

//If you want to remove blog_usernames_blog from $link, put this in template.php

/* duplicate theme_links() and add the 3rd line (marked with HERE) */
function phptemplate_links($links, $attributes = array('class' => 'links')) {
  $output = '';

  // HERE: just add this line, the rest are from theme_links() 
  unset($links['blog_usernames_blog']);
  
  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = $key;

      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= ' first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
        $class .= ' active';
      }
      $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';

      if (isset($link['href'])) {
        // Pass in $link as $options, they share the same keys.
        $output .= l($link['title'], $link['href'], $link);
      }
      else if (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $output .= /*'<span'. $span_attributes .'>'.*/ $link['title'] /*.'</span>'*/;
      }

      $i++;
      $output .= "</li>\n";
    }

    $output .= '</ul>';
  }

  return $output;
}

Thanks again CK Ng!!! - my PHP skills aren't too great, but hopefully I get it working soon!

wildpoppy’s picture

Depending on the theme you are using you may be able to make this change through the admin page.

Most themes have an option to deselect the content types you don't want this information displayed for.

wildpoppy’s picture

Sorry. I've done this twice today.

What I should have asked is whether you might be able to just hide the display using a display: none style in the css

fresh-off’s picture

heh heh.. i feel dumb now. display: none worked.
Its my first complex theme from scratch, so i guess my line of thinking was to make sure it wasnt included, rather than "commenting" it out. I'm still looking forward to the day when i have more control over the output of my content types, but i guess that's just the learning curve!

thanks wildpoppy!!!

edit: for anybody reading this thread later on, display: none works, but it seems to have left some interesting spacing issues with the rest of the Unordered List. At first glance however, if you've got moderate CSS skills it should be easy enough to take care of.

ckng’s picture

fresh-off, you are welcome =)

Check that you don't have other hook_links, esp. YOURTHEME_links(), the only think which should prevent the code from working.
You can try this instead, a shorter version, without the <?php ?> tags (used here for syntax highlight to work only)

<?php
function phptemplate_links($links, $attributes = array()) {
    unset($links['blog_usernames_blog']);
    return theme_links($links, $attributes);
}
?>

phptemplate_links() can be replaced by YOURTHEME_links()

Using CSS display:none has 1 drawback, thing like search engine will still see it. =)

slee713’s picture

Thanks; worked perfectly!

For others: make sure you take out the php tags that ckng mentioned. I skimmed over his instructions and missed that part initially.

WorldFallz’s picture

_
Care about the future of the Drupal.org forums? Please join our conversation and show support for improving the forums infrastructure.

jroels’s picture

a module called "blog title" allows you to hide the "authors blog" link
http://drupal.org/project/blogtitle

dawnieando’s picture

Don't know whether this is what you are after but I was rooting to find out how to remove the posted by etc name, date from various elements on the page and was reading Drupal 6 Themes. The book advised to go to admin/build/themes and click the configure link at the side of your chosen default theme. There you will see a tab called 'global settings'. In there is an option to remove author (posted by, etc), date and so on from various content options across your site e.g. page, story, etc.

Switch off the ones that you don't want displayed, hit save and no longer do the names and dates of postings and comments appear in your content.

Sorry, if this is not what you were after. After spending some time trying to find this particular thing myself I thought it might be useful to someone out there as we do all tend to be rooting for similar solutions on drupal.org.

thanks

dawnieando’s picture

admin -> themes -> configure -> global settings -> Turn author name off (choose the various node / content types you want to NOT display author details for. Its built into drupal so no need to hack the code.

cesar.brod@gmail.com’s picture

I couldn't find the option to do this on D7. Is there an alternative to remove the author info only from a news content type (only the author info, not the submitted date)

WorldFallz’s picture

yep... in d7 it was moved to the individual content type settings.

_
Care about the future of the Drupal.org forums? Please join our conversation and show support for improving the forums infrastructure.

cesar.brod@gmail.com’s picture

Thanks, although it applies for author and date submitted. I would like to be able to remove only the author info...

WorldFallz’s picture

that's all that core provides. If you want to customize it, then you should deselect it in the content type, and create your own template file (either node.tpl.php for all content types, or node-{type}.tpl.php for a specific content type) to put it where/how you want.

_
Care about the future of the Drupal.org forums? Please join our conversation and show support for improving the forums infrastructure.