Jump to content

Community

Developer Documentation

core/Profile

What it is

A Profile extension allows you to add a tab to user profiles on the front end. Blog and Gallery use this extension to show the user's blogs and the user's gallery albums, respectively, on separate tabs on the user's profile.

How to use

The extension defines 3 methods and a property by default

    /**
     * Member
     */
    protected $member;
    
    /**
     * Constructor
     *
     * @param    \IPS\Member    $member    Member whose profile we are viewing
     * @return    void
     */
    public function __construct( \IPS\Member $member )
    {
        $this->member = $member;
    }

The constructor accepts an instance of \IPS\Member and stores it in a property. You can perform any other essential setup here as well, if needed.

    /**
     * Is there content to display?
     *
     * @return    bool
     */
    public function showTab()
    {
        return TRUE;
    }

The showTab() method returns a boolean value to indicate if the tab should be shown or not. This can be used in order to only show tabs if the user has any actual data to be shown. For instance, the gallery albums tab is not shown if the user has not created any gallery albums.

    /**
     * Display
     *
     * @return    string
     */
    public function render()
    {
        return 'content to display';
    }

Finally, the render() method returns the content to display when the tab is clicked on, as raw HTML output. You can use \IPS\Helpers\Table instances here to facilitate the display of data, or output completely custom HTML. If you need to output any CSS from your application, you can do that as well here.


  Report Document


×
×
  • Create New...