By florin on
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
Nice patch, thanks
For what it's worth, I'm using it and I like it :) Thanks!
Sorry, don't know how to patch...
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
It's pretty easy to apply a patch manually
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.
Works like a charm...
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
Cygwin
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.
Thanks for the info
Hope to take a look soon!
___________________
discover new oceans
lose sight of the shore
Updated patch for 4.7
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
4.7-friendly patch
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
easier built in solution
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
Hmm. Don't understand what you mean...
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
Tried it..
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
Turn off BOM
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.
Thank you, it works.
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
works great...
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.
Setting not saved?
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?
It worked!
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
confirmed for 5.0 RC2
The patch for 4.7 still works with 5.0 RC 2, although the line numbers have changed
options for core?
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?
Also confirmed for 5.1
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
I can't believe that there
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
blog.module should use the theme engine
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
- ...
For those who do not wish to patch Drupal core
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
or
or something similar.
Just wrap that statement in this "if":
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.
Hi 2hills, I am using
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
Sorry but you aren't
Sorry but you aren't following my comments :-D How do you get
from
?
Title is never = "blog" so you never print your title.
Cheers
Rob
using phptemplate themes and wanting to modify blog layout
for those using phptemplate themes and wanting to modify blog layout read this http://drupal.org/node/44699
reply to: phptemplate themes to mod blog layout
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.
updated patch for version 5.3
I updated my site to 5.3, so here's a version of the patch that works with 5.3:
--
Florin Andrei
http://florin.myip.org/
Solution (Hopefully)
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 :
Step 2 : Then, in node-blog.tpl.php, you can use :
-- 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 ;)
florin's patch works in 5.5 too
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.
My fault, actually.
I'm really sorry, I overlooked something.
I've changed the implementation, try this :
Add the function :
to your template.php. Then put this in node-blog.tpl.php :
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 .
How exactly?
I can't get it to work and in Drupal 6 but hopefully sykora will make a new post.
Bad parameter list... ?
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:
.cw.
.cw.
Removes link in teaser, not in full entry
@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?
http://www.thesitewizard.com/
http://www.thesitewizard.com/blogging/remove-username-from-drupal-blog.s...
Yes, That works in Drupal 6
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.
This works
This works for me in both the teaser overview als the full page.
one possibility
replace the print $link with this manually coded piece of html without the link to the blog:
--
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
I made a bug report for this
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/
ThnX ThnX ThnX very much!
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!
where i must put this ?
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
Help to remove this link on
Help to remove this link on Travels-blog
this post explains how to
this post explains how to remove the $user's blog link for drupal 6 :
http://drupal.org/node/324796