| View previous topic :: View next topic |
| Author |
Message |
Afwas Forum helper
 Joined: 03 Jan 2007 Posts: 3559
    votes: 63
|
Posted: Sat Jan 17, 2009 12:53 Post subject: [plugin] Remember Categories plugin |
|
|
This little plugin will remember the last active category you used in a blog instead of returning to the Category with the lowest number next time you wrote a post.
If you write a post the cehcked Cat will be 2 (Welcome) if you didn't change that name. So you must deliberately set your Cat if you want to change that. Wouldn't it be easier if it just remembered the last Cat you used.
See this post for a hack: [Solved] How to suggest another category?. Thanks to sam2kb for pointing in the right direction.
AstonishMe and Amazing Discoveries teamed up and wrote this little gem that remembers the state of the Category and Extra Categories. So simply install this one and you'll never accidentally write your posts in 'Welcome' again.
Download: remember_cat_plugin_0.3
Have fun _________________

Join us at irc://irc.freenode.net#B2evolution
More B2evo goodies at http://www.blog.hemminga.net
Last edited by Afwas on Sun Jan 18, 2009 2:41; edited 1 time in total |
|
| Back to top |
|
 |
sam2kb da ruski mafia
Joined: 02 Dec 2007 Posts: 2927
   votes: 53
|
Posted: Sat Jan 17, 2009 14:54 Post subject: |
|
|
Got an error trying to make posts from images (file manager)
Fatal error: Call to a member function set_setting() on a non-object in /../_remember_cat.plugin.php on line 102 _________________ Russian b2evolution | Download |
|
| Back to top |
|
 |
Afwas Forum helper
 Joined: 03 Jan 2007 Posts: 3559
    votes: 63
|
Posted: Sat Jan 17, 2009 15:19 Post subject: |
|
|
Please try in line 121:
| PHP: |
|
if ($this->Settings->get ( 'extra_cats' ) && $Blog->get_setting ( 'save_extra_cats' )) {
|
If you didn't generate or edit a post this setting doesn't exist (yet). I think that's the issue.
Better would be to instantiate the setting upon installing the plugin. Will see to that.
Thanks for reporting.
--F _________________

Join us at irc://irc.freenode.net#B2evolution
More B2evo goodies at http://www.blog.hemminga.net |
|
| Back to top |
|
 |
sam2kb da ruski mafia
Joined: 02 Dec 2007 Posts: 2927
   votes: 53
|
Posted: Sat Jan 17, 2009 15:55 Post subject: |
|
|
The fix doesn't work.
you need something like this...
| PHP: |
function AfterItemUpdate($params)
{
if( !is_object($params ['Item']->Blog) )
{
$BlogCache = & get_Cache( 'BlogCache' );
$Blog = & $BlogCache->get_by_ID( $params['Item']->blog_ID );
}
else
{
$Blog = & $params['Item']->Blog;
}
$Blog->set_setting ( 'save_main_cat', $params ['Item']->main_cat_ID );
$Blog->set_setting ( 'save_extra_cats', implode ( ',', $params ['Item']->extra_cat_IDs ) );
$Blog->dbupdate ();
}
|
It doesn't use "last selected" category anyway, but at least it fixes the error  _________________ Russian b2evolution | Download |
|
| Back to top |
|
 |
Afwas Forum helper
 Joined: 03 Jan 2007 Posts: 3559
    votes: 63
|
Posted: Sat Jan 17, 2009 16:36 Post subject: |
|
|
I was thinking something during plugin install but that won't help. Or at least it would need to loop through all available blogs.
I want to see if ¥åßßå can narrow this down to a oneliner.
--F _________________

Join us at irc://irc.freenode.net#B2evolution
More B2evo goodies at http://www.blog.hemminga.net |
|
| Back to top |
|
 |
¥åßßå Blonde Bimbo
 Joined: 07 Jan 2005 Posts: 6579
    votes: 115
|
Posted: Sun Jan 18, 2009 1:54 Post subject: |
|
|
| PHP: |
if( empty( $params['Item']->Blog ) )
{
return;
}
|
¥ _________________ I may have opened the door but you entered of your own free will
| normal life wrote: |
yabba_hh: I think, I type, I read what I type, I think "fuck, what was I thinking when I typed that?!"
tuxnus: that's two more thoughts than I give you credit for |
|
|
| Back to top |
|
 |
Afwas Forum helper
 Joined: 03 Jan 2007 Posts: 3559
    votes: 63
|
|
| Back to top |
|
 |
EdB /bb|[^b]{2}/
Joined: 05 Jan 2004 Posts: 7123
  votes: 90
|
Posted: Tue Jan 20, 2009 0:05 Post subject: |
|
|
| Please forgive me for asking without testing, but will this remember both main-cat and any sub-cats? |
|
| Back to top |
|
 |
¥åßßå Blonde Bimbo
 Joined: 07 Jan 2005 Posts: 6579
    votes: 115
|
Posted: Tue Jan 20, 2009 4:22 Post subject: |
|
|
Yep
¥ _________________ I may have opened the door but you entered of your own free will
| normal life wrote: |
yabba_hh: I think, I type, I read what I type, I think "fuck, what was I thinking when I typed that?!"
tuxnus: that's two more thoughts than I give you credit for |
|
|
| Back to top |
|
 |
John the uncertain
Joined: 22 Jun 2004 Posts: 2147
     votes: 27
|
Posted: Tue Jan 20, 2009 5:08 Post subject: |
|
|
Sweet plugin Afwas... oh, and le "blonde". _________________ See the Sites in in Venice |
|
| Back to top |
|
 |
|