I've seen various requests on the forum for a setting to remove the "$user's blog" link based on a setting accessible to the admin. I made one of those requests in the past.
There are various reasons to do that, most of them gravitating around usability.

Here's a patch against 4.6.0 to add an admin setting that, if disabled, will remove the "$user's blog" link from the blog nodes.
Seems to work fine on my blog: http://florin.myip.org/blog/
Please add the patch (or a washed-up version of it) to the Drupal code base.

diff -ru modules.old/blog.module modules/blog.module
--- modules.old/blog.module     2005-04-12 12:46:45.000000000 -0700
+++ modules/blog.module 2005-04-26 11:23:52.998470690 -0700
@@ -229,7 +229,7 @@
 function blog_link($type, $node = 0, $main = 0) {
   $links = array();

-  if ($type == 'node' && $node->type == 'blog') {
+  if (variable_get('show_blog_author_link', 1) == 1 && $type == 'node' && $node->type == 'blog') {
     if (arg(0) != 'blog' && arg(1) != $node->uid) {
       $links[] = l(t("%username's blog", array('%username' => $node->name)), "blog/$node->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name))));
     }
diff -ru modules.old/node.module modules/node.module
--- modules.old/node.module     2005-04-11 09:39:40.000000000 -0700
+++ modules/node.module 2005-04-26 11:22:50.478431132 -0700
@@ -613,6 +613,7 @@
   $output .= form_select(t('Number of posts on main page'), 'default_nodes_main', variable_get('default_nodes_main', 10), drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), t('The default maximum number of posts to display per page on overview pages such as the main page.'));
   $output .= form_select(t('Length of trimmed posts'), 'teaser_length', variable_get('teaser_length', 600), array(0 => t('Unlimited'), 200 => t('200 characters'), 400 => t('400 characters'), 600 => t('600 characters'), 800 => t('800 characters'), 1000 => t('1000 characters'), 1200 => t('1200 characters'), 1400 => t('1400 characters'), 1600 => t('1600 characters'), 1800 => t('1800 characters'), 2000 => t('2000 characters')), t("The maximum number of characters used in the trimmed version of a post.  Drupal will use this setting to determine at which offset long posts should be trimmed.  The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc.  To disable teasers, set to 'Unlimited'. Note that this setting will only affect new or updated content and will not affect existing teasers."));
   $output .= form_radios(t('Preview post'), 'node_preview', variable_get('node_preview', 0), array(t('Optional'), t('Required')), t('Must users preview posts before submitting?'));
+  $output .= form_checkbox(t('Display blog author link'), 'show_blog_author_link', 1, variable_get('show_blog_author_link', 1)==1 ? TRUE : FALSE, t("If this option is enabled, a link to the author's blog will be displayed on each blog item."));

   print theme('page', system_settings_form($output));
 }

Comments

Wes Cowley’s picture

For what it's worth, I'm using it and I like it :) Thanks!

Marc Bijl’s picture

Would be great if you can please describe what changes should be made in what file. I'm not a programmer, have limited access and do not understand linux. The only thing I can do is editing a file with an editor.

Many thanks in advance!

___________________
discover new oceans
lose sight of the shore

Geary’s picture

Read the patch text line by line and interpret it like this:

Lines beginning with --- and +++ show you the file to edit.

Lines beginning with @@ show you the line numbers involved.

After each @@ line is a chunk of source code. In that code, lines beginning with - should be removed, and lines beginning with + should be added. Lines beginning with a space are unchanged and are shown to help provide some context for you to make sure you're at the right place in the code.

It's common to find a - line immediately followed by a + line. This is where a line has been changed.

In a patch that has several @@ chunks for a single file, it helps to apply them in reverse order, starting with the last one. That way the line numbers won't change. If you start from the beginning, then the subsequent line numbers will be hard to follow if the number of lines changes as a result of the edit. The patch in this post has only one chunk per file so this won't be an issue.

That's really all there is to it.

Or you can get a patch utility for your personal computer and apply the patch that way. But for a patch as simple as this one it only takes a few minutes to apply it manually.

Marc Bijl’s picture

Hi Michael,

Thanks for the quick reply and your instructions. It works like a charm now!

BTW
Do you know such a - free - patch utility you mentioned? (I use Windows XP)

Cheers,
Marc

___________________
discover new oceans
lose sight of the shore

Geary’s picture

Sorry, I should have mentioned... Cygwin is one good way to get a collection of Unix tools, including patch, on your Windows machine. I think there are some others too.

Marc Bijl’s picture

Hope to take a look soon!

___________________
discover new oceans
lose sight of the shore

Binary Blonde’s picture

Thanks so much for the patch. This is exactly what I was looking for.

Could it possibly be updated for use in 4.7?

binaryblonde.com

mherbison’s picture

I think this works in 4.7. If not, please let me know. This is the same as florin's original patch (from basically exactly one year ago) -- the syntax just had to change a bit for the node.module file to follow 4.7 conventions. I also like to put some comments in when I deviate from the standard install. -Matt

diff -upr modules.old/blog.module modules/blog.module
--- modules.old/blog.module	2006-03-27 13:02:48.000000000 -0500
+++ modules/blog.module	2006-04-28 00:39:46.000000000 -0400
@@ -247,7 +247,10 @@ function blog_view(&$node, $teaser = FAL
 function blog_link($type, $node = 0, $main = 0) {
   $links = array();
 
-  if ($type == 'node' && $node->type == 'blog') {
+  /* The following "show_blog_author_link" line is a Drupal 4.7 patch to provide the option to show or hide the "<user>'s blog" byline on posts. */
+  /* This patch works in concert with another in the node.module file */
+  /* Based on suggestions at http://drupal.org/node/21373 */
+  if (variable_get('show_blog_author_link', 1) == 1 && $type == 'node' && $node->type == 'blog') {
     if (arg(0) != 'blog' || arg(1) != $node->uid) {
       $links[] = l(t("%username's blog", array('%username' => $node->name)), "blog/$node->uid", array('title' => t("Read %username's latest blog entries.", array('%username' => $node->name))));
     }
diff -upr modules.old/node.module modules/node.module
--- modules.old/node.module	2006-04-07 11:32:17.000000000 -0400
+++ modules/node.module	2006-04-28 00:40:28.000000000 -0400
@@ -779,6 +779,17 @@ function node_configure() {
       1600 => t('1600 characters'), 1800 => t('1800 characters'), 2000 => t('2000 characters')),
     '#description' => t("The maximum number of characters used in the trimmed version of a post.  Drupal will use this setting to determine at which offset long posts should be trimmed.  The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc.  To disable teasers, set to 'Unlimited'. Note that this setting will only affect new or updated content and will not affect existing teasers.")
   );
+  
+  /* The following "show_blog_author_link" section is a Drupal 4.7 patch to provide the option to show or hide the "<user>'s blog" byline on posts. */
+  /* This patch works in concert with another in the blog.module file */
+  /* Based on suggestions at http://drupal.org/node/21373 */
+  $form['show_blog_author_link'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Display blog author link'),
+    '#return_value' => 1,
+    '#default_value' => variable_get('show_blog_author_link', 1)==1 ? TRUE : FALSE,
+    '#description' => t('If this option is enabled, a link to the author\'s blog will be displayed on each blog item')
+  );
 
   $form['node_preview'] = array(
     '#type' => 'radios', '#title' => t('Preview post'), '#default_value' => variable_get('node_preview', 0),
sherifomran’s picture

hallo Every body, there is an easier solution,

create a new story and write what you want and from the themes, general setting, remove the author details and it will be done.

If you dont understand what i mean, please read above.

kind regards,
Sherif

Marc Bijl’s picture

This post is about removing the link "$user's blog" (e.g. the link "marc's blog") just below a blog post. More specifically, about creating a switch which makes it possible to turn this on or off in the administration area. So, it's not about removing "submitted by $user" (e.g. "submitted by marc"). Last mentioned can indeed be administered by changing theme settings.

Now I'm just wondering: is your solution about the same link talking we're talking about? If so, can you please be a little more specific about how to remove that link? I don't understand...

___________________
discover new oceans
lose sight of the shore

Binary Blonde’s picture

Thanks for the patch. I installed it using UnxUtils patch program and it gave me this error:

patch: **** malformed patch at line 5: function blog_link($type, $node = 0, $mai
n = 0) {

Any clues as to what I can change to correct this error?

Thanks!

Edit: Okay, tried this by editing the node and blog module files manually and got this:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/bi/binaryblonde.com/modules/node.module:1) in /var/www/html/bi/binaryblonde.com/includes/bootstrap.inc on line 523

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/bi/binaryblonde.com/modules/node.module:1) in /var/www/html/bi/binaryblonde.com/includes/bootstrap.inc on line 524

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/bi/binaryblonde.com/modules/node.module:1) in /var/www/html/bi/binaryblonde.com/includes/bootstrap.inc on line 532

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/bi/binaryblonde.com/modules/node.module:1) in /var/www/html/bi/binaryblonde.com/includes/bootstrap.inc on line 540
Ð

I am using the Blue Bars theme, heavily modified. Not sure if that has something to do with sending the headers already.
---------------------------------------
Visit me @ binaryblonde.com

heine’s picture

Your editor saves UTF-8 byte order marks. They start output to the browser, leading to this error. Turn this feature off and all should be well.
--
When your problem is solved, please post a follow-up to the thread you started.

Binary Blonde’s picture

Thank you, Heine. You are correct. The patch works perfectly when I used another program to apply it. I appreciate the help!

And thank you for the patch, Matt!

Visit me @ binaryblonde.com

rootwork’s picture

but it took me a long time to figure out that the "setting accessible to the admin" was specifically in administer > settings > posts. you might want to include that in any future documentation.

cvuijlst’s picture

I installed the 4.7.3. patch in Drupal 4.7.3, but when I check the checkbox the option isn't saved... Anything I'm doing wrong?

hos’s picture

Thank you for this code. Although it was a little hard to understand at first, I figured it out and modified the blog.module and node.module. AND IT WORKED!

Thanks again!

Michael S. Copeland
www.mscopeland.com

Anonymous’s picture

The patch for 4.7 still works with 5.0 RC 2, although the line numbers have changed

kvarnelis@drupal.org’s picture

This kind of thing shouldn't have to be done via a patch. Drupal is supposed to be flexible. Shouldn't this be an option in core that we can control?

Marc Bijl’s picture

The patch for 4.7 (manually applied - because line numbers have been changed) works like a charm with 5.1!

___________________
discover new oceans
lose sight of the shore

gn0rt0n’s picture

I can't believe that there isn't something in the admin already to do this. If it has been a request for this long, why are we having to apply a patch?

Does anyone have an updated patch for 5.1 so we don't have to manually edit the files?

TIA

twohills’s picture

the real issue is that blog.module does not theme any of its outputs. if it did use this standard Drupal mechanism then we could theme all sorts of aspects of the display, such as
- changing the title (what this patch is about)
- displaying entries in reverse order (a blog with most recent at the bottom)
- two columns
- ...

twohills’s picture

For those who do not wish to patch Drupal core... do it in the theme:

Somewhere in the page template or _page routine, depending on the theme engine, the theme will either

      print $title;

or

      $output .= "<h2>$title</h2>";

or something similar.

Just wrap that statement in this "if":

    if (!(arg(0) == 'blog' && is_numeric(arg(1)) && is_null(arg(2)))) {
      ...
    }

It will still say "Rob's blog" on the window titlebar, but you can even eliminate that by using the same if elsewhere in the theme where it builds the

I'm never keen to patch core.

Anonymous’s picture

Hi 2hills,

I am using K2.
Following your comments, I have modified the page file to the following code: (couldn´t wrap the statement)

if ($title == 'blog'): print '<h2 class="entry-title'. ($tabs ? ' with-tabs' : '') .'">'. $title .'</h2>'; endif;

But then, all titles are erased whether in the blog listing of posts or in the posts themselves.
I want only the "John´s blog" title of the list of post to be erased.

Could you help me with that?

Michaël

twohills’s picture

Sorry but you aren't following my comments :-D How do you get

if ($title == 'blog'): 

from

if (!(arg(0) == 'blog' && is_numeric(arg(1)) && is_null(arg(2)))) {

?

Title is never = "blog" so you never print your title.

Cheers
Rob

twohills’s picture

for those using phptemplate themes and wanting to modify blog layout read this http://drupal.org/node/44699

me13’s picture

twohills

Just want to remove the "$user's blog" but don't know php.

Is it possible to simply add your: "if (!(arg(0) == 'blog' && is_numeric(arg(1)) && is_null(arg(2)))) { }" statement (from your previous post) to a "node-blog.tpl.php" file and if so, what would I add between the end brackets?

Sorry for the question but really stuck with this.

florin’s picture

I updated my site to 5.3, so here's a version of the patch that works with 5.3:

diff -ru modules.old/blog/blog.module modules/blog/blog.module
--- modules.old/blog/blog.module        2007-04-23 10:05:11.000000000 -0700
+++ modules/blog/blog.module    2007-11-24 00:31:47.000000000 -0800
@@ -233,7 +233,7 @@
 function blog_link($type, $node = NULL, $teaser = FALSE) {
   $links = array();
 
-  if ($type == 'node' && $node->type == 'blog') {
+  if (variable_get('show_blog_author_link', 1) == 1 && $type == 'node' && $node->type == 'blog') {
     if (arg(0) != 'blog' || arg(1) != $node->uid) {
       $links['blog_usernames_blog'] = array(
         'title' => t("@username's blog", array('@username' => $node->name)),
diff -ru modules.old/node/node.module modules/node/node.module
--- modules.old/node/node.module        2007-09-29 16:41:28.000000000 -0700
+++ modules/node/node.module    2007-11-24 00:35:01.000000000 -0800
@@ -1012,6 +1012,11 @@
     '#options' => array(t('Optional'), t('Required')), '#description' => t('Must users preview posts before submitting?')
   );
 
+  $form['show_blog_author_link'] = array(
+    '#type' => 'radios', '#title' => t('Show blog author link'), '#default_value' => variable_get('show_blog_author_link', 0),
+    '#options' => array(t('No'), t('Yes')), '#description' => t('Show user\'s blog link below blog post?')
+  );
+
   return system_settings_form($form);
 }
 

--
Florin Andrei
http://florin.myip.org/

sykora’s picture

I think I've come up with a general solution to the problem which avoids a core hack but it requires the themesettingsapi module. As far as I can tell however, the functionality of that module is included in drupal 6 core, so having the module isn't necessary afterwards. It does almost the same thing as florin's patches.

Step 1 : Follow http://drupal.org/node/177868 to create a theme-settings.php file in the theme's directory. Here's mine :

<?php
function phptemplate_settings($saved_settings) {
    $defaults = array(
        'show_blog_author_link' => 0,
    );

    $settings = array_merge($defaults, $saved_settings);

    $form['show_blog_author_link'] = array(
        '#type' => 'checkbox',
        '#title' => t('Show blog author\'s link in posts'),
        '#default_value' => $settings['show_blog_author_link'],
    );

    return $form;
}

?>

Step 2 : Then, in node-blog.tpl.php, you can use :

<?php
$show_link = theme_get_setting('show_blog_user_link');
if ($show_link) {
    unset($node->links['blog_usernames_blog']);
}
?>

-- somewhere before you display the links.

This is my first attempt at posting a drupal hack, so don't flame me if it's been posted before ;)

susata’s picture

Because it seems like the theme settings approach would be more elegant, I really tried to get Sykora's fix to work -- but just could not. I'm sure it was something I was doing wrong... but I finally just lost patience and turned to Florin's patch for 5.2, which works great in my 5.5 installation.

s.

sykora’s picture

I'm really sorry, I overlooked something.

I've changed the implementation, try this :

Add the function :

function _rebuild_links($link_array) {
    $output = '';
    $links_final = array();
    foreach($link_array as $link) {
        $links_final[] = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $link['html']) ;
    }
    return $output;
}

to your template.php. Then put this in node-blog.tpl.php :

$show_link = theme_get_setting('show_blog_author_link');
        if (!$show_link) {
            unset($node->links['blog_usernames_blog']);
        }
        print _rebuild_links(' | ', $node->links);

Note 1 : The second code snippet is to be used in place of the "print $links".
Note 2 : You'll still need the phptemplate_settings code from my last post.

What I had overlooked was that although the setting was being properly retrieved, unsetting the link made no difference because the links had already been preprocessed! The best solution, of course, is to do this work in the actual template_preprocess_node, but I'm not sure how that works in 5.x . I've got it working in 6.x though, if anyone's interested. It also helps that themesettingsapi is in core in 6.x .

Chippe’s picture

I can't get it to work and in Drupal 6 but hopefully sykora will make a new post.

chrisfromredfin’s picture

This doesn't look right either, _rebuild_links doesn't take two parameters...

I just did this with these two lines at the top of node-blog.tpl.php, before $links is printed out:

unset($node->links['blog_usernames_blog']);

$links = theme('links', $node->links);

.cw.

.cw.

spiffyd’s picture

@cwells...

Your 2 liner did it for the links under the teasers, however "User's blog" links still show up under the node view. Is there any way to disable those as well?

egtalbot’s picture

Thanks Spiffyd for the link. If I ever enabled users to have blogs on my site, it's also easy to see how I could change the commenting out to an if statement with my admin user so that it gave the link for everyone except the admin user, which would be reasonable.

joostvdl’s picture

This works for me in both the teaser overview als the full page.

valderama’s picture

replace the print $link with this manually coded piece of html without the link to the blog:

<ul class="links inline">
		<li class="comment_comments"><a href="./?q=node/<?php print $node->uid; ?>#comments" title="Jump to the comments of this posting."><?php print $node->comment_count; ?> comment(s)</a></li>
		<li class="node_read_more last"><a href="./?q=node/<?php print $node->uid; ?>" title="Read the rest of <?php print $node->title; ?>.">Read more</a></li>
	</ul>		

--

keine zeit für spielkonsolen mein leben ist jump n run!

valderama.net

--

keine zeit für spielkonsolen mein leben ist jump n run!

valderama.net

florin’s picture

I made a bug report for this issue, please add any relevant comments you may have:

http://drupal.org/node/324796

--
Florin Andrei
http://florin.myip.org/

Johnson2’s picture

Such a perfect patch, but doesn't work in Google Browser [Google Chrome]. I checked others out! It's working perfectly.

Thanks again! xD I LEARNED A LOT from doing this!

cakka’s picture

where i must put this patch ?
please explain me ?
are this will influence all node ?

how if i just want remove the user link in blog node ?

thanks

---
www.ckcybers.com

kl_admin’s picture

Help to remove this link on Travels-blog

batigolix’s picture

this post explains how to remove the $user's blog link for drupal 6 :

http://drupal.org/node/324796