How to get all sub-folders of a folder in HippoCMS

147 views
Skip to first unread message

sharad...@gmail.com

unread,
Jul 26, 2016, 11:52:11 AM7/26/16
to Hippo Community
Hi Team,

I am using HippoCMS 10.2.1 and I have below folder structure

ProductCatalogue - Root Folder
-HomeCare - Sub Folder
 - en_gb - Sub Folder
 - de_de - Sub Folder
 - fr_fr - Sub Folder

Now I want to get all folders and folder names from /content/documents/productcatalogue/homecare folder.

I am doing it like below: But i am getting NULL in second line. Line no 2 in returning NULL.

HippoBean root = requestContext.getSiteContentBaseBean();
HippoBean bean = root.getBean("/content/documents/productcatalogue/homecare");
if (bean.isHippoFolderBean()) {
HippoFolderBean folder = (HippoFolderBean) bean;
List<HippoFolderBean> folders = folder.getFolders();
for (HippoFolderBean hippoFolderBean : folders) {
folderList.add(hippoFolderBean.getName());
}
}

Please help me, How can I do that ?

Thanks & Regards,
Sharad Jain 

sharad...@gmail.com

unread,
Jul 27, 2016, 12:15:34 AM7/27/16
to Hippo Community, sharad...@gmail.com
Hi Team,

Please help me in resolving this issue ASAP.

Thanks & Regards,
Sharad Jain

Jasper Floor

unread,
Jul 27, 2016, 4:16:46 AM7/27/16
to Hippo Community, sharad...@gmail.com
Hi,

the getBean method takes a relative path. So your 'root' bean is already at some location (most likely '/content/documents/site'). This will be configured on you hst:site node as a property hst:content. So root.getBean('homecare') is ProductCatalogue is your site base bean.

If ProductCatalogue is not your site root then you will need to approach it another way. You could get the parent bean and work from there:

root.getParentBean.getBean(...)

of get the root of the repository:

request.getRequestContext().getSession().getRootNode()

In any case you have to use a relative path.

mvg,
Jasper


--
Hippo Community Group: The place for all discussions and announcements about Hippo CMS (and HST, repository etc. etc.)
 
To post to this group, send email to hippo-c...@googlegroups.com
RSS: https://groups.google.com/group/hippo-community/feed/rss_v2_0_msgs.xml?num=50
---
You received this message because you are subscribed to the Google Groups "Hippo Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hippo-communi...@googlegroups.com.
Visit this group at https://groups.google.com/group/hippo-community.
For more options, visit https://groups.google.com/d/optout.

sharad...@gmail.com

unread,
Jul 27, 2016, 5:14:24 AM7/27/16
to Hippo Community, sharad...@gmail.com
Hi Jasper,

Thanks for your reply. It worked for me :)

Regards,
Sharad Jain

Jasper Floor

unread,
Jul 27, 2016, 6:44:03 AM7/27/16
to Hippo Community, sharad...@gmail.com
On Wed, Jul 27, 2016 at 11:14 AM, <sharad...@gmail.com> wrote:
Hi Jasper,

Thanks for your reply. It worked for me :)

Glad to hear it. Thanks for letting us know.

mvg,
Jasper
Reply all
Reply to author
Forward
0 new messages