·¬ÇÑÉçÇø

Brightspot CMS Developer Guide

Profile tabs


The header contains a link to display the current user’s profile in a widget. The default implementation displays two tabs in the widget: Profile and History.

Default profile tabs Default profile tabs


You can add custom tabs to the profile widget by extending the class. The following example creates a My Articles profile tab that lists the current user’s 10 most recently published articles.

import com.psddev.dari.util.PaginatedResult;
import content.article.Article;

public class MySummaryTab extends ProfilePanelTab { 

    @Override
    public void writeHtml(ToolPageContext page) throws IOException, ServletException { 

        UUID uuid = page.getUser().getId();

        PaginatedResult<Article> articles = Query.from(Article.class) 
                .where("cms.content.publishUser = ?", uuid)
                .sortDescending("cms.content.publishDate")
                .select(0, 10);

        List<Article> myArticles = articles.getItems();

        page.writeStart("div", 
                "class", "p-tud-lg tabbed",
                "data-tab", "My Articles");
            page.writeStart("h1");
                page.writeHtml("My Articles");
            page.writeEnd();
            page.writeStart("h2");
                page.writeHtml("The following table lists your 10 most recently published articles.");
            page.writeEnd();
            page.writeStart("table");
                page.writeStart("tr");
                    page.writeStart("th");
                        page.writeHtml("Headline");
                    page.writeEnd(); /* th */
                    page.writeStart("th");
                        page.writeHtml("Date Activity");
                    page.writeEnd(); /* th */
                page.writeEnd(); /* tr */

                for (Article article : myArticles) { 
                    page.writeStart("tr");
                        page.writeStart("td");
                            page.writeHtml(article.getHeadline());
                        page.writeEnd(); /* td */
                        page.writeStart("td");
                            page.writeHtml(article.getPublishDate());
                        page.writeEnd(); /* td */
                    page.writeEnd(); /* tr */
                }

            page.writeEnd(); /* table */
        page.writeEnd(); /* div */
    }
}
  • Declares a class that extends from ProfilePanelTab—the class that outputs to a custom profile widget.
  • Overrides the method writeHtml, which directs output to the custom tab.
  • Retrieves the current user’s 10 most recently published articles.
  • Creates the new tab with the label My Articles. Any nested page.write statements write to this tab.
  • Loops through the found articles and output the headline and date published for each.

Custom profile tab Custom profile tab

See also:

Previous Topic
Tabs
Next Topic
Adding areas to the navigation menu
Was this topic helpful?
Thanks for your feedback.
Our robust, flexible Design System provides hundreds of pre-built components you can use to build the presentation layer of your dreams.

•
•
•
Brightspot is packaged with content types that get you up and running in a matter of days, including assets, modules and landing pages.

• Content types
• Modules
• Landing pages
Everything you need to know when creating, managing, and administering content within Brightspot CMS.

• Dashboards
• Publishing
• Workflows
• Admin configurations
A guide for installing, supporting, extending, modifying and administering code on the Brightspot platform.

• Field types
• Content modeling
• Rich-text elements
• Images
A guide to configuring Brightspot's library of integrations, including pre-built options and developer-configured extensions.

• Google Analytics
• Shopify
• Apple News