[plugin] Remember Categories plugin

 
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions
View previous topic :: View next topic  
Author Message
Afwas
Forum helper

Joined: 03 Jan 2007
Posts: 3559
Reputation: 28.7Reputation: 28.7Reputation: 28.7 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 63

PostPosted: Sat Jan 17, 2009 12:53    Post subject: [plugin] Remember Categories plugin Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger
sam2kb
da ruski mafia

Joined: 02 Dec 2007
Posts: 2927
Reputation: 162.4Reputation: 162.4 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 53

PostPosted: Sat Jan 17, 2009 14:54    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Afwas
Forum helper

Joined: 03 Jan 2007
Posts: 3559
Reputation: 28.7Reputation: 28.7Reputation: 28.7 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 63

PostPosted: Sat Jan 17, 2009 15:19    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website Yahoo Messenger
sam2kb
da ruski mafia

Joined: 02 Dec 2007
Posts: 2927
Reputation: 162.4Reputation: 162.4 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 53

PostPosted: Sat Jan 17, 2009 15:55    Post subject: Reply with quote

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 Neutral

_________________
Russian b2evolution | Download
Back to top
View user's profile Send private message Visit poster's website
Afwas
Forum helper

Joined: 03 Jan 2007
Posts: 3559
Reputation: 28.7Reputation: 28.7Reputation: 28.7 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 63

PostPosted: Sat Jan 17, 2009 16:36    Post subject: Reply with quote

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. Razz

--F

_________________

Join us at irc://irc.freenode.net#B2evolution
More B2evo goodies at http://www.blog.hemminga.net
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
¥åßßå
Blonde Bimbo

Joined: 07 Jan 2005
Posts: 6579
Reputation: 29.5Reputation: 29.5Reputation: 29.5 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 115

PostPosted: Sun Jan 18, 2009 1:54    Post subject: Reply with quote

PHP:
if( empty( $params['Item']->Blog ) )
{
  return;


Wink

¥

_________________
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
View user's profile Send private message Visit poster's website
Afwas
Forum helper

Joined: 03 Jan 2007
Posts: 3559
Reputation: 28.7Reputation: 28.7Reputation: 28.7 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 63

PostPosted: Sun Jan 18, 2009 2:40    Post subject: Reply with quote

Version 0.3 with fix released. See https://sourceforge.net/project/showfiles.php?group_id=160495&package_id=306566
Thanks sam2kb, thanks ¥åßßå

_________________

Join us at irc://irc.freenode.net#B2evolution
More B2evo goodies at http://www.blog.hemminga.net
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
EdB
/bb|[^b]{2}/

Joined: 05 Jan 2004
Posts: 7123
Reputation: 140.9 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 90

PostPosted: Tue Jan 20, 2009 0:05    Post subject: Reply with quote

Please forgive me for asking without testing, but will this remember both main-cat and any sub-cats?
Back to top
View user's profile Send private message
¥åßßå
Blonde Bimbo

Joined: 07 Jan 2005
Posts: 6579
Reputation: 29.5Reputation: 29.5Reputation: 29.5 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 115

PostPosted: Tue Jan 20, 2009 4:22    Post subject: Reply with quote

Yep Wink

¥

_________________
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
View user's profile Send private message Visit poster's website
John
the uncertain

Joined: 22 Jun 2004
Posts: 2147
Reputation: 4.6Reputation: 4.6Reputation: 4.6Reputation: 4.6 add or subtract from this member's reputationadd or subtract from this member's reputation
votes: 27

PostPosted: Tue Jan 20, 2009 5:08    Post subject: Reply with quote

Sweet plugin Afwas... oh, and le "blonde".
_________________
See the Sites in in Venice
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    b2evolution Forum Index -> Plugins & Extensions All times are GMT - 5 Hours
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
b2evolution Support Forum RSS Feed Forums powered by php Bulletin Board