1 rhellem Feb 06, 2014 20:48
3 rhellem 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 mgsolipa 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 rhellem Feb 15, 2014 23:49
6 rhellem Feb 16, 2014 10:58
And when all is done, I stumbled across this feature "Move a category" http://b2evolution.net/man/user-guide/faq/move-a-category
...but, way cooler doing it using SQL than just pressing a button ;-)
7 mgsolipa Feb 16, 2014 11:16
8 jibberjab 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 mgsolipa 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 jibberjab 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 mgsolipa 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 jibberjab 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.
13 jibberjab May 15, 2014 22:32
bump^
14 mgsolipa 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 jibberjab 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.
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.