HI,

When showing the main-page of a user blog, I got the link called "weblogs" in the breadcrumbs. I don´t like how that weblogs-page (which shows the latest blog-posts of all users) is displayed and want to do an own view substituting this page.

I already tried to overwrite it, by:

  1. creating an alias from "/blog" to "/community/blogs.html"
  2. setting up the page-view with the same URL

Sadly it seems the standard blog-page overwrites the view url, not the opposite, so I still got the standard drupal-blogs-page at this url and not my view.

By the way: For Blog Posts, it isn´t a problem, I can just do a custom breadcrumb for them, but not for the main user-blog page.

For breadcrumbs, I already got this in my template.php (if it could only be done trough the template.php) :

<?php 
function test_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) {
    foreach($breadcrumb as $value) {
        $crumbs .= ''.$value.'&nbsp;&raquo;&nbsp;';
    }
  }
  return $crumbs;
}

?>

Thanks for any help,
Marc

Comments

karc2008’s picture

I made it by using rules.

(Please note, that I´m using the german version, so I don´t know the exact english terms used by drupal)

  1. I set on event to "Node -> If content displayed"
  2. I set "If content type is Blog Entry"
  3. finally at "Do" I selected "Select Breadcrumbs" and placed it in the way, I wanted it to be

The breadcrumbs of the posts inside the blog like "/user/1/blog/somepost.html" are set by custom breadcrumbs, and this rule did not cause conflicts with those settings (I feared there would be a conflict).

A long time I tried "If Path has alias" and put in the blog-path (in my case /user/[author:uid]/blog.html). Without any success and just as an act of despair, I tried the content type.

So happy I got rid of that breadcrumb without doing php-stuff in template.php, I don´t really understand.

Hope this will help someone in the same situation.

boblangdon’s picture

If I understand your question correctly, I had a similar problem and this worked for me...

  1. Create a new View displaying your blog index however you'd like it to appear.
  2. To prevent the DEFAULT "blog index" page from displaying ("www.yoursite.com/blog"), point your NEW "blog index" path to the same as the default: "www.yoursite.com/blog" ("/admin/build/views/edit/my_custom_blog_index" >> Page Setting: Path). That will make the default "blog index" GO AWAY, never to be seen again.
  3. Then use Path_Alias (/admin/build/path) to give it whatever alias you'd like ("/blog" >>> "/community/blogs.html," for example). This will change the URL, making it more user/SEO-friendly
  4. The link text: "Blogs" will still appear in your navigation menu, however.
    Change it to whatever you'd like at: "/admin/build/menu-customize/navigation."
  5. Changing the link text in breadcrumbs isn't something I've thought about. "Blogs" works fine for me. It shouldn't be too difficult, however.

    My first though would be to add a "phptemplate_breadcrumb($breadcrumb)" override to "template.tpl.php" and then use PHP's "str_replace" function to change the text to whatever you'd like it to read.

    For example: str_replace("Blogs","Custom Link Text","$breadcrumb",1)

    Hope that helps.
    YMMV

boblangdon’s picture

OK, I just HAD to give this a try. This works for me:

function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb)) 
	$count=1;
	$breadcrumb=str_replace("Blogs","Custom Link Text",$breadcrumb,$count);
    return '<div class="breadcrumb">'. implode(' >> ', $breadcrumb) .'</div>';
  }
}

If you want all occurrances of "Blogs" to be changed to "Custom Link Text" (or WHATEVER"), just remove the $count variable (it tells it to only replace the FIRST occurance).

boblangdon’s picture

Ooops -- Now the breadcrumb is "unclickable!"

You have to include the link:

$breadcrumb=str_replace("Blogs","<A href=\"http://www.MySite.com/community/blogs.html\">Custom Link Text</a>",$breadcrumb,$count);
boblangdon’s picture

The whole "$count" thing won't work after all. You'll need to use PHP's "preg_replace" function if you want to replace ONLY the first 1 (or 2 or 3 or whatever) instances of "Blogs." To replace them all, stick with "str_replace." PHP's "preg_replace" function is much slower than "str_replace."

function phptemplate_breadcrumb($breadcrumb) {
  if (!empty($breadcrumb))
$breadcrumb=preg_replace("/Blogs/","<a href=\"Whatever\">Custom Link Text</a>",$breadcrumb,1);
    return '<div class="breadcrumb">'. implode(' >> ', $breadcrumb) .'</div>';
  }
}

Of course, if you're changing the link text from "Blogs" to something like: "My Site's Blogs" then you're obviously going to get into some trouble here, because you'll end up changing "My Site's Blogs" to: "my Site's My Site's Blogs" (Arghh!). Working on that.

boblangdon’s picture

Of course, if you're changing the link text from "Blogs" to something like: "My Site's Blogs" then you're obviously going to get into some trouble here, because you'll end up changing "My Site's Blogs" to: "My Site's My Site's Blogs" (Arghh!). Working on that.

Well that was easy enough (DOH!). Simply go back to using str_replace and forget the whole "count" thing.

Check to see if it's "Blogs" and not "My Site's Blogs" by including the delimiters (">>" -- or whatever you're using for delimiters) in the string to search for.

$breadcrumb=str_replace(">> Blogs",">> Custom Link Text",$breadcrumb);

OK. This risks getting pretty convoluted. I'll go away now.
B^/

karc2008’s picture

It was quite easy, since I understood, how to set up the rule correctly (or at least in this case correctly)

Thanks anyway for your efforts.

boblangdon’s picture

I guess I misunderstood:

Sadly it seems the standard blog-page overwrites the view url, not the opposite, so I still got the standard drupal-blogs-page at this url and not my view.

How does changing the breadcrumbs change what display you see (drupal default blogs page or your new view)? What happens now if someone go to the url: "www.YourSite.com/blog"?

karc2008’s picture

I think, I got rid of the last link to it. At least, I can´t find any link on my site, that points to /blog anymore... so it´s basically the same.

I never was troubled, that the url /blog is not available (for other content, than the standard "all-blogs-display"), I just didn´t want anyone, to go on this page (because it doubles with the view and I didn´t like the display), I just want to hide this page totally from users.

Even Search Engines won´t get the /blog-page, because nothing links on it. Where else should a link to this page be? I searched very hard, to get sure, I got rid of it.

Maybe, I didn´t notice another link, but I searched really hard for it. And in case someone puts in this url by hand, I will just redirect it to my connected Wordpress-Blog (blog.mypage.com) or the new blog-view-page.

I´m sure, this solution won´t work for every case, but in mine, I think, it worked.

And sorry, if I didn´t describe the problem clear enough.

boblangdon’s picture

Ahh, I see. You just want to change the links pointing to the default Blogs page. In that case, your solution works very well indeed.
:-)
My experience has been that old "system links" (for lack of a better phrase) have a habit of popping up when and where I least expect them, as the site grows and changes. I'd rather fix a problem while I'm thinking of it than "mask" it and have it reappear in the future to bite me.

Anyway, I had fun playing with this. Maybe someone with special circumstances will find my bit of "mental masturbation" helpful some day.
8^S

PS: Speaking of search engines, you might want to exclude the default view from being indexed by adding it to your "robots.txt" file. Just to be safe.

Cheers.