Skip to:
Content
Pages
Categories
Search
Top
Bottom

How use bp widgets in a non-widget theme or other cases


  • nicolagreco
    Participant

    @nicolagreco

    Hi guys,

    i’m an italian php developer, i think i’m the youngest guy that is trying wordpress.

    So, when i have a non-widget wordpress theme, generally, i add code to widgetize it, but sometimes i need a non-widget theme.

    In wordpress when i use non-widget theme, i put code like <?php wp_tag_cloud(); ?> and if it’s possible i costumize the tag cloud adding some piece of code, like <?php wp_tag_cloud(‘largest=30’); ?> (I hope this code it’s correct).

    In buddypress if i put the <?php bp_core_widget_members() ?> in my sidebar.php for example it return an error, that says that it can’t use extract that requires the function’s argument, bp_core_widget_members($args).

    What do i have to put on $args ? and how can i use widgets in non-widget theme?

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

  • Burt Adsit
    Participant

    @burtadsit

    I just glanced at the code for the members, who’s online, groups widgets and see that, yes, they want an arg. No default is specified. What they are looking for is an array argument. As far as I can see none of the widgets are using that args array yet. Try a dummy arg.

    $my_dummy_arg = array(‘this is useless’);

    bp_core_widget_members($my_dummy_arg);

    or

    bp_core_widget_members(array(‘nothing to see here move along’));

    It’s complaining about a PHP function extract() that the widget uses at the top of the widget function. extract() wants an array. Give it one. ;)


    nicolagreco
    Participant

    @nicolagreco

    Ok it works, but if i would decide how many members it has to display, what do i have to write?

    for example bp_core_widget_members(‘members-max=10’);

    does something similar exist?


    Burt Adsit
    Participant

    @burtadsit

    Well, I don’t see any way of modifying the behavior of the widget with args at all. What we’re missing here is a template tag type function that takes the place of just using the widget as a widget. It’s after midnight so maybe I’m just missing it in the code someplace.

    I see examples all over the place of widgets like the standard wp ‘archive’ widget that displays a selection of months in a sidebar. There is also the template tag wp_get_archives(‘type=monthly’) that takes the place of a user selecting that widget, configuring it and then loading a page where the widget should display.

    Such a thing doesn’t seem to exist for bp and the core widgets yet. Besides that, calling the members widget like that doesn’t include some javascript that the widget depends on.

    Looks to me like you’re going to get default behavior with that call. Like I said, maybe I’m missing something. Anybody else got a suggestion?


    nicolagreco
    Participant

    @nicolagreco

    Thanks burtadsit for your insterest,

    today i’m at home, and i can read widgets’ code,

    and i can i will write some code line and i will update you..

    if someone can help drop us a line ;)


    Burt Adsit
    Participant

    @burtadsit

    Well, a good place to start would be the widget code itself.

    Let’s take the ‘archives’ widget as an example. I look at the widget code in: /wp-includes/widgets.php for the archive widget function: function wp_widget_archives($args), I see that it extracts the stored widget options and then eventually calls the template function: wp_get_archives(‘param=xxx&param=yyy’). The widget is just a wrapper for the template function that allows blog admins to set the behavior of the template function that does all the work.

    We need to pull the guts out of the members widget and create a template tag that does the work by parameters only. Looking at the archive widget again I see some code that sets up defaults, parses the passed args and then turns the args array into vars with extract().

    We could also just modify the widget to parse and actually pay attention to passed args.

    In any case did I mention that ‘We don’t need no stinking help’. (that was my best Mexican bandito accent). I forgot you are Italian. That was a reference to a Western movie. Never mind. I gotta go play with something else right now but I’ll return to this.


    nicolagreco
    Participant

    @nicolagreco

    Ok, but i’ve seen the code yesterday, but the bp’s widget retrieve options directly from wordpress configuration, i wrote some lines of code to add personalization feature, i will post code as soon as possible

    Nicola,


    @burtadsit
    , that’s my skype greco.nicola and that’s my e-mail: notsecurity@gmail.com


    Maxaud
    Participant

    @maxaud

    Any luck with limiting the number of members?


    gaysurfers
    Participant

    @gaysurfers

    Sorry can you guys explain how to
    I pasted in sidebar.php
    I get the error
    Now where do i paste:
    $my_dummy_arg = array(‘this is useless’);
    bp_core_widget_members($my_dummy_arg);

    or

    bp_core_widget_members(array(‘nothing to see here move along’));

    ??
    Thanks for your help

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How use bp widgets in a non-widget theme or other cases’ is closed to new replies.
Skip to toolbar