Skip to:
Content
Pages
Categories
Search
Top
Bottom

Short code to call My Widgets nav

  • Avatar of nit3watch
    nit3watch
    Participant

    @nit3watch

    Playing around with your plug-in @imath and Im loving it. Had a glance at the code though Im struggling to find the My Widgets function is as I would like to call it on my home page..

    Could you point me to the function as Its abit confusing with the sub navs and stuff.

    And thanks for such a awesome plug-in and taking the time to write it up.

    Ill also write up a few widgets though I not sure how you would go about adding widgets to the wp respiratory. If you could fill me in on how you think I should go about it, as the widgets are ‘with-in’ the plug-in.. how would you install new widgets or if you’d just ship the plug-in with new widgets..

Viewing 17 replies - 1 through 17 (of 17 total)
  • Avatar of imath
    imath
    Moderator

    @imath

    Hi @Nit3watch

    I’m happy you love this plugin. Since i uploaded it to the WordPress Plugins Directory yesterday, i didn’t find the time to explain how to build a new widget and precisely what function is called in order to display it when going to the “(siteurl)/members/(user)/my-home/” page. Sorry for that ;)

    So i’ll try to do it here (hope u’ll understand my english ;) ) :

    1/ you have to make sure to name the directory of your widget the same way than the php file that will contain the main functions.
    ex : my-widget/my-widget.php
    name of the directory ‘my-widget’ = name of the php file ‘my-widget’.php

    2/ the directory my-widget must be in the directory /wp-content/plugins/bp-my-home/widgets

    3/ The headers of the php file are important because they include informations that will be necessary once the Admin activated the widget from the WordPress backend (BPMH Manager)
    `/*
    bpmh widget name: My Example
    bpmh widget function: bpmh_example
    bpmh widget column: 1
    bpmh widget URI: http://example.com/widget_page
    bpmh widget Description: Example of Widget.
    bpmh widget Author: Mr Example
    bpmh widget Author URI: http://example.com/
    */`
    this is the header of the example widget i included within the plugin.
    the `bpmh widget function: bpmh_example` line tells what will be the first part of the function to call or use for configuration, display or customisation of the title.

    for example, in your php file your widget displaying function will be the value of `bpmh widget function`so here it’s `bpmh_example`plus `_widget_display`
    `function bpmh_example_widget_display(){
    echo “test”;
    }`

    for the title of the box, here’s is the function :
    `function bpmh_example_dragbox_title(){
    echo “your title”;
    }`

    If you want to add a screenshot of your widget in the my-settings page, the function is
    `function bpmh_example_user_settings(){
    ?>
    <img src=’path 2 your image’>
    <?php
    }`

    finally if you want to add the configure link (top right of the box)
    `function bpmh_example_dragbox_config_link(){
    ?>
    <a href=”javascript:void(0)” onclick=”name_of ur_javascript_function()”>Configure</a>
    <?php
    }`

    Back to the headers of the php file.
    the `bpmh widget column: 1` line indicates what will be the default column in which the widget will be displayed (possible values are 1 or 2)

    Actually you can start building your own by modifying the `wp-content/plugins/bp-my-home/widgets/bpmh-example/bpmh-example.php` file.

    I didnt think about the way to store new widgets or make some available.. I dont know what is the best solution.. What i know is that i will make possible to upload a widget to the proper directory from the BPMH Manager area.

    For today, you simply have to drop the widgets into the `bp-my-home/widgets/` directory

    I hope this reply will help you !! Thks a lot for this forum post :)

    Avatar of nit3watch
    nit3watch
    Participant

    @nit3watch

    Wow thats nicely written out and clear, thanks. For now should I just email you the widgets I write and you could include them in the latest version of BP My Home ( thats if you like the widgets :P ) untill you find a solution?

    Also what I was trying ask is if I wanted the ‘widget area’ (see below image) on my home page, what could I call? Like http://pastebin.com/LrPSTPVr
    ( Its the screen on wordpress/members/admin/my-home/ )

    Avatar of imath
    imath
    Moderator

    @imath

    For the first part, i’d say why not ;)

    For the second part, it needs to write more lines of code !! may be to write another plugin. From my point of view :
    1. as the actual widgets need infos about the logged in user (in order to get_user_meta widgets data),
    2. as the widgets are not visible by others than the loggedin user
    3. as the home page is a place to display posts or a static page for visitors

    I found the solution of redirecting the member to his “(siteurl)/members/(user)/my-home” page more interesting. Actually if the member goes to his “(siteurl)/members/(user)/my-settings”, he can set his widget page to be his homepage as soon as he’s logged in.

    Avatar of nit3watch
    nit3watch
    Participant

    @nit3watch

    I have 2 different content area’s for my home page, one for logged-in users and one for new visitors. I don’t want to redirect them to their profile page. What I currently have is normal wordpress “widget area’s” on my home page though I would like to replace them with your “movable widget area”, ( a widget area using BP My Home widgets ).

    I just need to know where the function that calls column1 and column2 is.. I think I’ll have a in depth look tomorrow because I don’t think you are understanding my question and Im not coming across clearly.

    Ill get back to you tomorrow.

    Avatar of nit3watch
    nit3watch
    Participant

    @nit3watch

    Ok, if you think about it:

    The sub nav ( My Widgets ) has to have these checks defined somewhere:

    1. as the actual widgets need infos about the logged in user (in order to get_user_meta widgets data),
    2. as the widgets are not visible by others than the loggedin user

    And then the function where 1 and 2 were checked is called in the sub nav hence displaying the image in the above post.
    Now how does the sub nav ( My Widgets ) call the widget area? If the subnav can call the widget area then surely we could call the widget area anywhere provided we have check if the user is logged in.

    Maybe someone ( @r-a-y or @DJPaul ) could help clarify this abit?

    Avatar of imath
    imath
    Moderator

    @imath

    Dont worry i understood, and i ran some tests before my last answer, BP My Home doesnt match this need for now (sorry :( )
    The solution i explored was
    1/ create a page template and inserting the function `<?php bp_my_home_load_widgets();?>`
    2/ create a page in WP and selecting this page template
    3/ set the page as the home page
    4/ adding the necessarly javascripts to the header and the php script that loads the widgets into my theme’s functions.php script :
    `function try_blog_home_page(){
    if(is_front_page()){
    wp_enqueue_script(‘jquery’);
    wp_enqueue_script( ‘jquery-ui-173′, BP_MYHOME_PLUGIN_URL . ‘/js/jquery-ui-1.7.3.custom.min.js’ );
    wp_enqueue_script( ‘bp-my-home’, BP_MYHOME_PLUGIN_URL . ‘/js/bp-my-home.js’ );
    wp_enqueue_style(‘my-home-style’, BP_MYHOME_PLUGIN_URL . ‘/styles.css’);

    //Loading active widgets
    $rep = BP_MYHOME_PLUGIN_DIR.’/widgets’;
    $active_widgets = get_option(‘_bpmh_activated_widgets’);
    if($active_widgets!=””) {
    foreach($active_widgets as $widget_key=>$widget_values){
    include_once($rep.’/’.$widget_key);
    }
    }
    }
    }

    add_action(‘get_header’, ‘try_blog_home_page’);`

    Result : the widgets are showing but ajax functions are not working.

    And again, it’s not the goal of the plugin.

    So If you want to add “sidebar widgets” and make them moveable/collapsible, you can do it without this plugin by simply make a template page and after `get_header` and before `get_sidebar`
    `<div class=”column” id=”column1″>
    <div class=”dragbox” id=”item-<?php echo $widget_ref;?>” >
    <div class=”handle_div”><h2> </h2></div>
    <h2>Widget 1</h2>
    <div class=”dragbox-content”>
    <?php if ( !function_exists(‘dynamic_sidebar’)
    || !dynamic_sidebar(‘widget 1′) ) : ?>
    </div>
    </div>
    </div>
    <div class=”column” id=”column2″>
    <div class=”dragbox” id=”item-<?php echo $widget_ref;?>” >
    <div class=”handle_div”><h2> </h2></div>
    <h2>Widget 2</h2>
    <div class=”dragbox-content”>
    <?php if ( !function_exists(‘dynamic_sidebar’)
    || !dynamic_sidebar(‘widget 2′) ) : ?>
    </div>
    </div>
    </div>
    <hr style=”clear:both;” />`

    then make the same step 2 and 3 and adapting step 4

    `function try_blog_home_page(){
    if(is_front_page()){
    wp_enqueue_script(‘jquery’);
    wp_enqueue_script( ‘jquery-ui-173′, ‘path_2_your_jquery-ui-copy’ );
    wp_enqueue_script( ‘anotherJS’, ‘path_2_anotherJS’ );
    wp_enqueue_style(‘your-style’, ‘path_to_your_styles.css’);
    }
    }

    add_action(‘get_header’, ‘try_blog_home_page’);`

    to build your anotherJS and your-style i advise you to read > http://webdeveloperplus.com/jquery/collpasible-drag-drop-panels/

    Avatar of nit3watch
    nit3watch
    Participant

    @nit3watch

    I was playing around abit with bp_my_home_load_widgets() and including the widgets in the my-home-core, didnt include the correct paths for the js but Ill have to look tomorrow – late now in SA :P

    Thanks for all the input though and I probably misread here and there so Ill go over everything in detail tomorrow..

    Cheers and thanks again

    Avatar of imath
    imath
    Moderator

    @imath

    you’re welcome, hope you’ll find your solution :)

    Just a last word on my plugin, i didn’t build it in order to display regular WordPress sidebar widgets, my goal was to add to the member area a nav to display custom widgets only viewable by the logged in user where he can put his bookmarks, feeds and others that i plan to build (notepad,…).

    I know that on Internet there’s a lot of tools doing so (iGoogle, Netvibes…), but i run an Intranet so these tools are not available to all. And Thanks to BuddyPress i’m able to give them something approaching…

    Cheers.

    Avatar of nit3watch
    nit3watch
    Participant

    @nit3watch

    Im going to take your advice and rather redirect the user to ‘my home’ and change my-home.php to suit my needs, its the same as having 2 content area’s on the home page with less complications.

    Your taking buddypress to the next level, “cloud operating system concept” like iGoogle and Eyeos and so on.. The only thing buddypress was missing was your plugin :P Im excited to see were your plugin is headed and soz for the headache last night, was jumping the gun.

    Avatar of imath
    imath
    Moderator

    @imath

    Ok, you can change my-home.php but you can also override the template from your theme’s directory. For example, in your `wp-content/themes/active_theme/` , if you add a folder `my-home-tpl` containing a copy of `my-home.php` file, then you can modify it and your template will automatically display instead of the one in `wp-content/plugins/bp-my-home/includes/templates/my-home-tpl` ;)

    And many thanks for the second part of your post !! :)
    Have a lovely day.

    Avatar of nit3watch
    nit3watch
    Participant

    @nit3watch

    override the template from your theme’s directory
    which would also prevent my changes being over-written when the plug-in is updated, “the right way to do it”.

    Avatar of imath
    imath
    Moderator

    @imath

    exactly :)

    Avatar of leoplaw
    Leo Plaw
    Participant

    @leoplaw

    Hi Imath.

    I just posted a question about modifying the template for my-home on your plugin website. I have just found the answer here:
    http://buddypress.org/community/groups/bp-my-home/forum/topic/short-code-to-call-my-widgets-nav/#post-79509

    Can you please for the sake of other users, add this information to the readme.txt file included with the plugin, and also to the plugin website. It will help many people and make it easier to use your wonderful plugin.

    I have just followed your instructions and successfully changed the template! 8)

    This plugin has great potential. Website visitors no longer want to be passive viewers and now expect to interact and order sites to their preferences. Your plugin is a step in that direction.

    Keep up the great work. Merci beaucoup.

    Avatar of imath
    imath
    Moderator

    @imath

    hi @leoplaw,

    Ok, i will add this info ;)

    Thanks.

    Avatar of lumenbeing
    lumenbeing
    Member

    @lumenbeing

    Really hoping I can get this plugin working right. Can you tell me or show me an example of where to stick that line of rss feed code? I can’t get it to work.

    Avatar of imath
    imath
    Moderator

    @imath

    First, you need to enable this feature in BPMH manager, then in your active theme paste the tag in the single.php just before the comment template tag for example.

    Avatar of maisonet
    maisonet
    Participant

    @maisonet

    Hi, I love this plugin. I have been wishing to find something like this for a long time. Thanks for sharing it. I have little experience with coding and need some direction to create a second My Home page and call it News, with it’s own set of widgets like My Home. In other words, I would like to expand the functionality of this plugin to have My Home page with it’s own set of widgets as it does now and be able to add another page called News with it’s own set of widgets. In short, how can I add another page or multiple pages like My Home with their own widgets?

Viewing 17 replies - 1 through 17 (of 17 total)

You must be logged in to reply to this topic.