Page 1 of 1
Remove category and all entries
Posted: Wed Jul 20, 2005 10:00 am
by mburger
Hello,
how to delete a category and all it's entries? If I click on the delete button next to a category I will be asked where to move the entries of that category.
But I don't want do move the entries, I want to remove the category and all it's entries...
Regards...
Re: Remove category and all entries
Posted: Wed Jul 20, 2005 11:36 am
by garvinhicking
Did you try to move the articles to the "No category" value?
Apart from this, Serendipity in its current state does not delete the entries, as it worships the entries as the most important item on your blog.
I recommend to go to the Edit Entries screen, sort the entries by Category and then delete the entries in that category first, and after that, remove the entries.
Regards,
Garvin
Posted: Wed Jul 20, 2005 12:20 pm
by mburger
Did you try to move the articles to the "No category" value?
No, I did not try that, it's a production system. I interpret that function in the way that it does not remove the entries, it just move the entries to the "unnamed" category.
I recommend to go to the Edit Entries screen, sort the entries by Category and then delete the entries in that category first, and after that, remove the entries.
In the category to be deleted there are several 100s entries. Manually deleting would be a pain.
Is there any function like "Delete (or make invisible) all entries in category x"?
Regards
Posted: Wed Jul 20, 2005 12:48 pm
by garvinhicking
Nope, I'm sorry. There isn't. For someone with PHP knowledge it would be easy to create such a plugin in less than an hour...
I don't see a large need for such a function, as in the 3 years of s9y development you are the first to request that.
This snippet of SQL code would do the trick on a MySQL 4.1 installation:
Code: Select all
DELETE FROM serendipity_entries WHERE id IN (SELECT entryid FROM serendipity_entrycat WHERE categoryid = 4)
And this could be adapted to PHP:
Code: Select all
<?php
mysql_connect('localhost', 'root', '');
mysql_select_db('serendipity');
$ec = mysql_query("SELECT entryid FROM serendipity_entrycat WHERE categoryid = 4");
while ($row = mysql_fetch_array($ec, MYSQL_ASSOC)) {
mysql_query("DELETE FROM serendipity_entries WHERE id = '{$row['entryid']}'");
echo "Deleted entry #{$row['entryid']}";
}
Blogs are usually there to archive content. People writing their diaries/blogs usually never want to delete their past, so Serendipity is built to serve that need and focusses to maintain the entries even when you re-categorize your entries.
Maybe if you tell me the reason you need to delete 100s of entries I can see a real need for this, and think about implementing a plugin. If I don't see the need myself, I still can be bribed to do it...
Regards,
Garvin
Posted: Wed Jul 20, 2005 3:41 pm
by gwilsonmail
I can think of a few reasons.
[1] replicate an existing blog so you get the same layout and plugins installed. Then you delete the entries and categories and start over.
[2] you have a category that is very popular and you want to make it a blog all by itself. So you essentially want to replicate the blog, delete the category and entry from the original and delete everything except the category from the new
Posted: Wed Jul 20, 2005 4:15 pm
by garvinhicking
[1] For that you would only migrate the serendipity_config and serendipity_plugins tables, plus your templates/ directory. You wouldn't copy a full blog.
[2] Well, Serendipity is more concepted that you turn a category into its own blog (use different templates depending on the selected category). So you wouldn't need to migrate entries anywhere, as you can keep them.
So you haven't yet convinced me.
Regards,
Garvin
Posted: Wed Jul 20, 2005 4:52 pm
by gwilsonmail
if i follow what you are saying about [2] I may not need multiple-blogs for what i am trying to do.
my blogs are lossly connected and seperate at the same time.
say we have categories for apple, oranges and radishes
so a single blog could be about fruit and vegetables . You could have another blog `(using the same articles) about apples and oranges and be called the fruit blog.
if radishes were to become fadish/popular a complete blog about radishes would be called for.
with your suggestion I could write and manage a single blog and "peel-off" blogs based on categories. And because i can put an article in multiple categories any article can now be in multiple blogs.
If this is possible then we are missing an awesome feature. b2evolution does this but i dropped that because the user interface drove me nuts! it was too easy to add a new article and end up publishing to the wrong blog!
another plus is the s9y support of sub-categories. So at anytime you can "peel-off" a category, make it a blog and the sub-categories are now the categories of the new blog.
awesome!
Tell me it's one line of code and it's possible to do in a plugin ....
Posted: Wed Jul 20, 2005 5:20 pm
by kidgoo
One possibility I could see for this would be the ability to make "private" entries...eg, entries for a personal journal that isn't world readable. These entries would be better suited to be in a hidden category than to be saved as drafts...
Just my thoughts
Brett
Posted: Wed Jul 20, 2005 8:51 pm
by garvinhicking
You could check the categories in your index.tpl like this:
Replace this:
Code: Select all
<link rel="stylesheet" type="text/css" href="{$head_link_stylesheet}" />
with:
Code: Select all
{if $serendipity.GET.category == 1}
<link rel="stylesheet" type="text/css" href="http://yourblog/style1.css" />
{else if$serendipity.GET.category == 2}
<link rel="stylesheet" type="text/css" href="http://yourblog/style2.css" />
{else}
<link rel="stylesheet" type="text/css" href="{$head_link_stylesheet}" />
{/if}
This would output different Stylesheets based on the Categoryid. For this to work you also need to create a "config.inc.php" in your template directory with this content:
Code: Select all
$serendipity['smarty']->assign('serendipity', $serendipity);
because otherwise you can't access the $serendipity global.
A more advanced version of a plugin or a config.inc.php patch can be to modify $serendipity['template'] depending on the selected category. This is pretty starightforward, but I currently don't have time to investigate and document this fully. But I do see it's possible and not very hard.
Regards,
Garvin
Posted: Thu Jul 21, 2005 6:37 pm
by gwilsonmail
I see how you can display a different style for each category.
But how would you filter categories so that one blog would have apples and oranges and another just apples and a third perhaps radishes?
Posted: Fri Jul 22, 2005 11:44 am
by garvinhicking
I would create my own categories plugin which only lists the subcategories of a selected blog? So you wouldn't see a link to all other categories...
Regards,
Garvin