Skip to:
Content
Pages
Categories
Search
Top
Bottom

JJJ What is this you reference in your word camp video?

  • Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Can you explain more about this code? How to use it?

    `class BP_Example_Component extends BP_Component {

    function __construct(){
    parent::start(
    ‘example’,
    __(‘Example’, ‘buddypress’),
    BP_PLUGIN_DIR
    );
    }

    function includes() {
    $includes = array(
    ‘actions’,
    ‘screens’,
    ‘template’,
    ‘functions’,
    );
    parent::includes($includes);
    }
    }
    `

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of r-a-y
    r-a-y
    Moderator

    @r-a-y

    That’s if you want to create a brand-new BP component by extending the base BP_Component class.
    This makes things way easy to manage and develop going forward!

    You can find examples throughout the BP 1.5 codebase (look at each subdirectory for bp-x-loader.php and stare at it until it melts into your head!).

    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    Easiest thing to do is check out the phpDoc in the code itself.

    https://buddypress.trac.wordpress.org/browser/trunk/bp-core/bp-core-component.php#L6

    Basically it requires a few basic parameters to identify the component, and calls the parent class function to put them into action.

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Should have looked first, man oh man the component code is so much cleaner. Well done, gents!

    Avatar of @modemlooper
    @modemlooper
    Moderator

    @modemlooper

    Ok, so tried to move some code from core to create a custom component and nothing worked. Never got a page to create and not sure how to link it to template files.

    For example: in bp-activity it has a file bp-activity-template.php and in include array there’s an entry ‘template’. Is this pointing to that file? Do we need to include all these files listed in the array? If I had bp-example-template.php in my array id still use ‘template’?

    To me it seemed much easier to create components before. I know I can still use old method but that won’t last forever.

    Can somebody update the skeleton component to reflect the new method?

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

You must be logged in to reply to this topic.