Recent Topics

1 Feb 06, 2014 20:48    

Right now running 5.0.6-stable on my homepage http://hellem.org/blog

Back in the days before I got to understand the use of categories I created multiple blogs - one "show'em all", then one for posts in Norwegian, one regular and one for CD's I bought (easier to understand what I am trying to describe if you look at my blog :-) )

Now I want to get rid of the "show'em all" blog and merge the three others, instead using categories. Is this doable without to much effort? Might be that I just have missed the correct search term when using Google, but until now I have not had any luck finding anyone who have done it already. I would expect it to be pretty straight forward using SQL, but I am a bit afraid to screw things up if I just let myself go wild since my knowledge of the various tables needed to be updated are best described as pretty limited...

2 Feb 07, 2014 10:43

Hi @rhellem,

As far as I know, there is no way to do that, but it's a pretty cool idea for a new plugin.

Thanks.

3 Feb 15, 2014 08:24

Found this post http://www.bigsoft.co.uk/blog/index.php/2008/09/28/b2evolution-deleting-a-category-with-man

I have managed to move the posts by using the following sql


UPDATE evo_items__item
SET post_main_cat_ID = <NEW CATEGORY ID IN NEW BLOG>
WHERE post_main_cat_ID = <OLD CATEGORY ID IN OLD BLOG>

Problem is that I still have to edit every post in order for it to be viewed in the correct blog. That is, when I select to EDIT the post it immediately update itself and is shown in the correct blog. So I only have to hit "Save" and it is shown in the new blog.

I have trided to delete the cache, but that did not do the trick.

4 Feb 15, 2014 11:46

Hello @rhellem,

Now I see you're hands on MySQL, then I could suggest how to do it directly in the database. The problem is that you updated only the main category at the evo_items__item table, but there is another table that saves al the relationship between an item and the categories: evo_postcats.Then you will need to use a query like this:


UPDATE  evo_postcats SET  postcat_cat_ID = [NEW CAT_ID] WHERE postcat_cat_ID = [OLD CAT_ID];

You have to be careful with items linked to several categories, the query above will work with posts linked to a single one, then you will have to run it with each category that belongs to your old blog.

Regards!

5 Feb 15, 2014 23:49

Thanks @mgsolipa

That did the trick!

Did test it out on my laptop first the two SQL's combined cleaned it up for me, now I have decreased the number of blogs on my installation from 6 to 3.

And in the same time I got to upgrade my blog to latest version, all in all a good evening!

7 Feb 16, 2014 11:16

@rhellem shame on me for my first comment on this post, I made it without doing a deeper research and lead you to a harder and "geekier" way. Thanks for sharing!

8 May 08, 2014 17:56

Just to clarify something here, in post #3, you have the following code:

UPDATE evo_items__item
SET post_main_cat_ID = <OLD CATEGORY ID IN OLD BLOG>
WHERE post_main_cat_ID = <NEW CATEGORY ID IN NEW BLOG>


Aren't the comments reversed?
You need to SET the NEW cat id.... WHERE X matches OLD id.

jj.

9 May 10, 2014 13:21

Aren't the comments reversed?

I guess I don't fully understand what you mean. In this case we are talking only about to the relation item-category. The comments are managed by a different relation that has nothing to do with this kind of changes. You could move items to any category and their comments will remain associated to them.

Regards!

10 May 10, 2014 15:30

I was referring to the comments inside the code he posted.

He posted the code:
SET post_main_cat_ID = with the comment <OLD CATEGORY ID IN OLD BLOG>
WHERE post_main_cat_ID = with the comment <NEW CATEGORY ID IN NEW BLOG>

Those are reversed. SET refers to NEW CATEGORY ID, and WHERE refers to OLD CATEGORY ID. It should be:

SET post_main_cat_ID = with the comment <NEW CATEGORY ID IN NEW BLOG>
WHERE post_main_cat_ID = with the comment <OLD CATEGORY ID IN OLD BLOG>

The code, as posted in post #3, is reversed, and if someone follows it as posted they're potentially going to create problems for themselves.

11 May 10, 2014 17:12

Ah! You're right! Thanks fo pointing that out, the placeholders were reversed indeed. I misunderstood your comment before, but now I edited that code and each placeholder is in its right position.

However, people definitely should not use that method at all. If someone needs to move a category, the correct method is described here: http://b2evolution.net/man/user-guide/faq/move-a-category

12 May 12, 2014 20:18

Right, that would be a safer way to do it. I've got another question related to this whole topic. I'm in a similar situation to the OP, and am considering consolidating 3 separate blogs into a single main blog, using categories instead of blog stubs, but I'm unclear on the 301 redirects. So, for example:

Old location:
mydomain.com/stubname5/2007/10/05/title_of_the_post
and old categories:
mydomain.com/stubname5/categoryname/subcategoryname/
and old blog:
mydomain.com/stubname5/

New location:
mydomain.com/2007/10/05/title-of-the-post (no more Blog 5 stubname, posts moved to new blog)
and new categories:
mydomain.com/categoryname/subcategoryname/ (no more Blog 5 stub name, categories moved to new blog)
and new blog:
mydomain.com/ (no more Blog 5 stubname, deletion of Blog 5)

There are a few things going on here, all of which I'm either planning, or considering:
1. replace underscore with hyphen in post titles (definitely will do)
2. move all categories, subcategories, and posts into one blog (probably will do if 301 redirects will work. I know how to move categories, but how is the 301 handled for an old location that no longer exists... In other words, if I move all posts and cats from Blog 5 into Blog 2, and remove (delete) Blog 5 from the backend, then how does b2evo handle the hit and the 301 from Blog 5 to Blog 2 if there is no more Blog 5 in the backend to handle the hit in the first place? I hope I'm describing that clearly.)
3. complete removal (deletion) of Blog 5 and its stubname (probably will do since moving all blogs to a single blog no longer requires unique stubs, but need to make sure that removing a stubname will 301 properly from domain/stubname/date/post --> domain/date/post)

jj.

14 May 16, 2014 07:18

@jibberjab the automatic 301 redirect will work only in a per-blog environment. For example, lets suppose that we have a post with two slugs: post1-slug and post1_slug, being the first one the canonical URL of the post. Whenever a request to http://mydomain.com/stub1/post1_slug is done, b2evo will redirect to http://mydomain.com/stub1/post1-slug.

In cases like yours, when you need a redirect from a URL that no longer exists (the whole category have been moved), you will need to manage the redirects directly in the .htaccess file. The following is an example that could work exactly as you need according with the examples you provided and assuming that the Blog 5 will be completly unavailable from now on.

RedirectMatch 301 /stubname5(.*) http://mydomain.com$1

15 May 16, 2014 16:22

Ah, ok, I'll do some testing with that. I'm still not 100% positive that I want to merge the blogs anyway, but it's good to know how just in case.

On another note, can you address the related topic of creating the 301 redirects directly in the database, discussed in this post: http://forums.b2evolution.net/topic-22771 You mentioned a scripted way to create the underscore to hyphen conversion... Thanks!

jj.


Form is loading...