Skip to:
Content
Pages
Categories
Search
Top
Bottom

Understanding bp_core_load_template


  • techguy
    Participant

    @crashutah

    I’m trying to understand what’s happening with the bp_core_load_template function. It’s working for a new subpage on a profile page, but I’d like to get it working under the group.

    Here’s the code I use for the profile page that works fine, but I’d like to learn what it’s really doing:
    function display_plugin_page() {
    add_action( ‘bp_template_content’, ‘display_content_for_this_page’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
    }

    Can anyone tell me what this code is doing? Why does it work for a profile page and not a group page? Also, I saw some reference to locate_template which sounds like it might do some similar things, but for custom templates?

    Shouldn’t I just be able to use the following display function in the group API for the new page to display what’s in the function display_content_for_this_page()?
    function display() {
    add_action( ‘bp_template_content’, ‘display_content_for_this_page’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘groups/single/plugins’ ) );
    }

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

  • Boone Gorges
    Keymaster

    @boonebgorges

    I must admit that I all the template redirection of BP and WP are somewhat magical and mysterious to me.

    What about just requiring the template? If you’re using the BP Group Extension API, you need to have a display() method; the content of the method could be to require the necessary template file. That’s what the BuddyPress Group Wiki plugin does.

    It’s helpful to look at a few plugins that have robust templating for their display: Group Wiki, Group Documents, and Group Blog all do it differently, but maybe they’ll point you in the right direction.


    techguy
    Participant

    @crashutah

    Boone,
    Thanks for the suggestions. I will take a look at the other group plugins. I looked at some, but didn’t have the ones you mentioned on my list to look at.

    I also tried just putting the content in the display() instead of trying to load a template and that’s working fine. So, I guess the question is why should I load a template versus just using my own code in display()?


    r-a-y
    Keymaster

    @r-a-y

    If you’re using your plugin internally, you don’t really have to worry about loading a template.

    Loading templates are useful for other BP themes.


    Boone Gorges
    Keymaster

    @boonebgorges

    What @r-a-y said. It can be nice to use templates if you think that other BP themes will possibly provide override template for what you’re building. Unless you’re building a BP plugin that has extremely rich functionality or can only work if it’s extremely customizable, I wouldn’t worry about it – just put the markup code directly into display(), or in a function that gets referenced in display(), or required as in the Group Wiki plugin.


    techguy
    Participant

    @crashutah

    OK. Good to know. I’ll save the templates for other plugin projects. Maybe someone can explain the details of how they work by then.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Understanding bp_core_load_template’ is closed to new replies.
Skip to toolbar