Search in sources :

Example 1 with HstSiteMenu

use of org.hippoecm.hst.core.sitemenu.HstSiteMenu in project hippo by NHS-digital-website.

the class IntranetEssentialsMenuComponent method doBeforeRender.

@Override
public void doBeforeRender(HstRequest request, HstResponse response) {
    super.doBeforeRender(request, response);
    Map<String, SocialMediaLink> socialMediaLinks = new HashMap<>();
    HstSiteMenu menu = (HstSiteMenu) request.getAttribute("menu");
    if (menu != null) {
        for (HstSiteMenuItem item : menu.getSiteMenuItems()) {
            if (item.getHstLink() != null) {
                String path = item.getHstLink().getPath();
                HippoDocument hippoBeanForPath = getHippoBeanForPath(path, HippoDocument.class);
                if (hippoBeanForPath instanceof SocialMediaLink) {
                    socialMediaLinks.put(path, (SocialMediaLink) hippoBeanForPath);
                }
            }
        }
    }
    request.setAttribute("socialMediaLinks", socialMediaLinks);
}
Also used : HippoDocument(org.hippoecm.hst.content.beans.standard.HippoDocument) HashMap(java.util.HashMap) HstSiteMenu(org.hippoecm.hst.core.sitemenu.HstSiteMenu) SocialMediaLink(uk.nhs.digital.website.beans.SocialMediaLink) HstSiteMenuItem(org.hippoecm.hst.core.sitemenu.HstSiteMenuItem)

Aggregations

HashMap (java.util.HashMap)1 HippoDocument (org.hippoecm.hst.content.beans.standard.HippoDocument)1 HstSiteMenu (org.hippoecm.hst.core.sitemenu.HstSiteMenu)1 HstSiteMenuItem (org.hippoecm.hst.core.sitemenu.HstSiteMenuItem)1 SocialMediaLink (uk.nhs.digital.website.beans.SocialMediaLink)1