1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Save Post 1.0

Save Post

  1. williamd

    williamd New Member

    williamd submitted a new resource:

    Save Post - Save Post

    Read more about this resource...
     
    Last edited by a moderator: Dec 22, 2014
    gabev, nothingman, davidshq and 3 others like this.
  2. Nick

    Nick Well-Known Member

    This is great! I love how it adds your saved links to the widget on the fly like that. Brilliant!

    Two suggestions to make it a bit better: ;)

    1. Remove the admin_plugin_settings and admin_sidebar_plugin_settings hooks because they aren't being used and cause a fatal error if you try to visit the settings page.

    2. Make a "templates" folder and put save_post_widget.php in it. Then, in the Text Widget, users can put
    PHP:
    $h->displayTemplate('save_post_widget''save_post');
    instead of needing to move the file to their theme folder. If they later move the file to their theme to customize, that code will still find it.
     
  3. williamd

    williamd New Member

    Hey Nick,

    Thanks! :) I had a lot of fun creating it. Hotaru makes it easy! I really appreciate your input and I just updated the package and this post accordingly. Should work a bit better now!

    As it is now, there is no limit on the amount of saved posts that are displayed in the sidebar. I guess that will be in ver. 0.3 along with a small admin interface or just inline buttons to remove items from the list in the widget. Who needs sleep anyway?
     
  4. Nick

    Nick Well-Known Member

    Thanks for making those updates!

    Future versions might use their own widget instead of the Text Widget, and show the latest (10) saved links in the widget with a "more" link that goes to all the links in a users profile. Currently the profile section from the Users plugin is a bit of a mess. We need a hassle-free way for plugin developers to add extra pages to user profiles. I'll give that some thought.

    The reason I would give Save Post its own widget is because in its current form, the widget title still shows to logged out users. Something like this would setup the widget:

    PHP:
    /**
         * Register Saved Post widget
         */
        
    public function install_plugin($h)
        {
            
    $h->addWidget('save_post''save_post''');  // plugin name, function name, optional arguments
        
    }

        
    /**
         * Displays Save Post widget
         */
        
    public function widget_save_post($h)
        {
            
    $h->displayTemplate('save_post_widget''save_post'); // template name, plugin name
        
    }
    In the template, you'd need to put a wrapper around the code, e.g.

    PHP:
    <h2 class='widget_head widget_save_post_title'>Saved Posts</h2>

    <
    div class='widget_body widget_save_post_body'>

    // output

    </div>
    The end result would look the same, but you'd have a bit more flexibility and not need the Text Widget.

    This is fun, eh? :-D
     
  5. rushnp774

    rushnp774 New Member

    Wow, sounds like a really awesome plugin. Thanks! The only thing I don't like is that now I'm going to have too many extra buttons in my _base_show_post_extra_fields field. My tags, tweet this, fb share, buzz, etc icons are all going to wrap around onto a new layer unless I figure something out. Any ideas Nick or William? Guess I could always just reduce the left padding between the icons, but I don't want to cram them together too close.

    This could probably be further extended by allowing people to email their favorites, or at least a selected favorite to other people. That'd just add another method for people to share posts they find helpful besides using social media buttons. I'm a huge fan of an "email this"-type button, because even people who don't use social media likely use email. I'd be happy to help out with that if you want William.

    Again, awesome stuff, and I'll get to testing it on my local development server.
     
  6. rushnp774

    rushnp774 New Member

    Hmm, probably something simple, but I have two problems with this plugin after installing it:

    1) The Save/Remove button only appears when I'm logged in as an admin. Is that supposed to happen?

    2) The text widget where I entered, "$h->displayTemplate('save_post_widget');" (without the quotes) gives me a "page not found" error when I run the page.

    The plugin is installed, and the text widget is activated & has the PHP box checked. I'm sure it's something tiny, but I'm not sure what I'm doing wrong. Any suggestions?
     
  7. williamd

    williamd New Member

    Nick, you're right. It makes much more sense to have it as its own widget. Code ahs been updated and uploaded! Thanks!
     
    Nick likes this.
  8. Nick

    Nick Well-Known Member

    Yes! you've prompted me to write one possible solution here.
     
  9. Nick

    Nick Well-Known Member

    Wow, you work fast! :eek:
     
  10. williamd

    williamd New Member

    Hiya!

    Yes, that's kinda how I wanted it - only to be shown for logged in users. That can be easily changed in save_post_widget.php - remove the if loggedIn statement. Then again, you should download the latest package and try that out instead and get all the widgety goodness! Much cleaner now.

    I hear you regardig the many buttons in sb_base_show_post_extra_fields. It can get a little crowded. An easy fix would be to change certain plugins to use sb_base_show_post_extras instead, which is in a div just below! A bit hacky, but it could work and give you a whole extra row to fill with plugins!
     
  11. williamd

    williamd New Member

    lol, not that hard when you provided the answer ;-)
     
  12. williamd

    williamd New Member

    Well... *cough* I added the wrong save_post_widget.php to the former zip. Get the 0.3.1 zip and you should be fine :) Sorry.
     
  13. williamd

    williamd New Member

    Small update - added an inline icon in the sidebar widget. Removes the list item on click.
     
  14. Nick

    Nick Well-Known Member

    Updated: v.0.5 2010/03/22 - Nick - Added a "Saved Posts" page in the user's profile

    The "Saved Posts" page works the same way as the widget, with a simple list of posts and the same button to remove them. The one big difference is that it's public. You can see any user's saved posts by going to their profile page and clicking "Saved Posts" from the menu.

    Having a "Saved Posts" page means that you can still take advantage of saving posts without enabling the widget. However, do note that the saved posts aren't paginated in this version, so if someone saves everything, they'll end up with a really, really long page of links! :p
     
  15. davidshq

    davidshq Member

    Love the public saved posts feature.
    Dave.
     
  16. williamd

    williamd New Member

    Really nice addon, Nick! Love it!
     
  17. Nick

    Nick Well-Known Member

    Updated: v.0.6 2010/04/17 - Nick - Fix for $h->vars['user'] clashing with other plugins (Hotaru 1.2)
     
  18. Moset

    Moset New Member

    Hi!

    Get this error in widget:

    Notice: Undefined index: saved_posts in /public_html/test/content/plugins/save_post/templates/save_post_widget.php on line 10

    and this in profile:

    Notice: Undefined index: saved_posts in /public_html/test/content/plugins/save_post/templates/save_post_page.php on line 12

    Trying to learn php :p but im no good yet
     
  19. Nick

    Nick Well-Known Member

    That's odd. I can't duplicate that at all. But never fear, a quick fix would be to change the offending lines from:

    PHP:
    if ( count($profile['saved_posts']) == ){
    to

    PHP:
    if ( !isset($profile['saved_posts']) || (count($profile['saved_posts']) == 0) ){
    If you're learning PHP, isset is used to check if a variable exists. The exclamation mark on the front means "not", so in this case you're saying "if 'saved_posts' doesn't exist or it's equal to zero, display the message, 'No saved posts'".
     
  20. Moset

    Moset New Member

    I only see the errors in debug mode but i dont like em hehe stable stable

    Thanks now the errors are gone :) and thanks for the tip !
     

Share This Page