Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to setup load_template_filter for new component with a directory page

  • Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    Am trying to figure out how to setup a component to use the new template hierarchy for it’s Directory page.

    I have a template (part) at /mycomponent/includes/templates/mycomponent/index.php

    And want that to be injected into a surrounding page (similarly to the way directory pages are handled for the default components.

    @r-a-y gives a good write covering use of the template hierarchy in relation to profile tabs: http://codex.buddypress.org/theme-compatibility/upgrading-older-plugins-that-bundle-custom-templates-for-bp-1-7/

    But, I’m struggling to see how to adapt this to component that has a Directory page (as well as other high level pages and new profile tabs).

    Any pointers to documentation / examples appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    a gentle 2 day bump

    Avatar of danbp
    danbp
    Moderator

    @danbp

    @rogercoathup

    hi Roger,

    no exact idea, but i would suggest you to take a look to the buddydrive plugin by @imath.
    The file buddydrive/includes/buddydrive-item-screens.php will probably help you to see how it’s made.

    You can also contact him directly, in case of: https://twitter.com/imath

    Regards. Dan

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    Hey Dan,

    thanks, yes, BuddyDrive looks to have the ‘correct’ solution.

    It creates a BP_Theme_Compat class for the component – the same approach that the internal components (Groups, Activity, etc.) do.

    @boone, @r-a-y … is that the recommended approach for 3rd party components going forward?

    Cheers,
    Roger

    Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    Hi Roger,

    Yes, you should try and follow how the BP components do it.

    View the BP_Activity_Theme_Compat class:

    https://buddypress.trac.wordpress.org/browser/tags/1.8/bp-activity/bp-activity-screens.php#L317

    And try and emulate that in your plugin. This is only for theme compat. That does not handle bp-default.

    If you want to support bp-default themes as well, let’s use the activity component again as an example.

    Check out bp_activity_screen_index():

    https://buddypress.trac.wordpress.org/browser/tags/1.8/bp-activity/bp-activity-screens.php#L13

    That adds support for bp-default. In that example, bp_core_load_template() tells BuddyPress to look for a template called ‘activity/index.php’ in your theme’s directory. If such a template exists, it will load it up the bp-default way.

    If it doesn’t, then BuddyPress will try and fallback to theme compat, which is where the BP_Activity_Theme_Compat class comes in for the activity component.

    Hope that clarifies things.

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    Hi R-a-y,

    Yes, had looked at the implementation in the default BP components, and ‘gotten’ my head around it.

    Good to get confirmation that this is the right approach for 3rd party as well.

    Thanks, Roger

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

You must be logged in to reply to this topic.