Yes, it's the solution when you want the search to go down one specific tree
at a time.

Bellow is a solution to retrieve all child pages of a parent page no matter
which tree.

StringBuffer allowedPagesStr = new StringBuffer(" AND (");
int pageInfoFlag = ContentPage.ACTIVE_PAGE_INFOS |
ContentPage.STAGING_PAGE_INFOS;
if (jData.gui ().isNormalMode ()) {
    pageInfoFlag = ContentPage.ACTIVE_PAGE_INFOS;
}

org.jahia.data.viewhelper.sitemap.TreeSiteMapViewHelper siteMapViewHelper =
      (org.jahia.data.viewhelper.sitemap.TreeSiteMapViewHelper)
       ServicesRegistry.getInstance().getJahiaSiteMapService().
                            getTreeSiteMapViewHelper (
                            jParams.getUser (),
                            jParams.getContentPage(), // starting parent
page
                            jParams.getSessionID(),
                            pageInfoFlag,
                            null, // any language
                            1);
siteMapViewHelper.expandAllPagesSubTree(0);
int size = siteMapViewHelper.size();
ContentPage contentPage = null;
for ( int i=0; i<size; i++ ){
      contentPage = siteMapViewHelper.getContentPage(i);
      allowedPagesStr.append("pageid:");
      allowedPagesStr.append(contentPage.getID());
      if ( i<size-1 ){
           allowedPagesStr.append(" OR ");
      }
}
allowedPagesStr.append(")");


Regards,
Khue Nguyen



----- Original Message ----- 
From: "ghislain.cussonneau" <[EMAIL PROTECTED]>
To: "dev_list" <[EMAIL PROTECTED]>
Sent: Tuesday, June 22, 2004 11:30 AM
Subject: Re:childs pages


Yes and it's very easy ...

Look at the example above : all sub pages of a page order by
date of creation.

        <%!

          public void getLastPages (JahiaPage cp, JahiaData
jData, SortedMap sortedMap, org.apache.log4j.Logger logger) {

            // Date de creation de la page
            long cpDate = -1;

            try {
              cpDate = (new Long (cp.getDoc()) ).longValue();
            } catch (Exception e) {
            }

            // Ajout de la page a la sortedMap
            sortedMap.put(new Long(cpDate), cp);

            // Recherche des sous-pages
            try {

              JahiaContainerList linkContainerList =
jData.containers().getAbsoluteContainerList( "linkContainer",
cp.getID() );
              if (linkContainerList != null) {

                Enumeration myContainerList =
linkContainerList.getContainers();
                if (myContainerList != null) {

                  while (myContainerList.hasMoreElements()) {

                    JahiaContainer myContainer =
(JahiaContainer) myContainerList.nextElement();
                    JahiaPage myLink = (JahiaPage)
myContainer.getFieldObject( "link" );
                    if (myLink != null){
                      getLastPages (myLink, jData, sortedMap,
logger);
                    }

                  }
                }
              }

            } catch (Exception e) {
            }

          }
        %>

        <!-- Arborescence des sous pages - DEBUT -->
        <%
          TreeMap sortedPages = new TreeMap();

          JahiaPage currentJahiaPage = jData.page();
          try {

            JahiaContainerList linkContainerList =
jData.containers().getAbsoluteContainerList( "linkContainer",
currentJahiaPage.getID() );
            if (linkContainerList != null) {

              Enumeration myContainerList =
linkContainerList.getContainers();
              if (myContainerList != null) {

                while (myContainerList.hasMoreElements()) {

                  JahiaContainer myContainer =
(JahiaContainer) myContainerList.nextElement();
                  JahiaPage myLink = (JahiaPage)
myContainer.getFieldObject( "link" );
                  if (myLink != null){
                    getLastPages (myLink, jData, sortedPages,
logger);
                  }

                }
              }
            }

          } catch (Exception e) {
          }
        %>
        <!-- Arborescence des sous pages - FIN -->

        <!-- Affichage des sous pages en ordre chronologique
inverse - DEBUT -->
        <%
          Object keys[] = sortedPages.keySet().toArray();
          int numElement = 1;

          for (int i=keys.length-1; i>=0; i--) {
            try {

              PageBean actualitePageBean = new PageBean (
(JahiaPage) sortedPages.get(keys[i]), jData.params() );

              if (isVisiblePageBean(actualitePageBean, jData)) {
                if (!isRubriquePageBean(actualitePageBean)) {

                  out.write(actualitePageBean.getTitle() +
"<br>");
                  numElement++;

                }
              }

            } catch (Exception e) {
            }
          }
        %>
        <!-- Affichage des pages en ordre chronologique
inverse - FIN -->




> Hello Khue Nguyen!
> Is there a possibility to retrieve the childs pageIds
knowing the parent pageId.
> I need to perform search down the certain tree, so it starts
from parent page and goes down to their childs.
>
> Thank you in advance
> Alex
> __________
> www.newmail.ru -- ????? ????? ??? ?????? ?????????.
>

Ghislain CUSSONNEAU
CRIL Technology
Technoparc de l'Aubini�re
44000 Nantes
02 51 89 64 50

Acc�dez au courrier �lectronique de La Poste : www.laposte.net ;
3615 LAPOSTENET (0,34?/mn) ; t�l : 08 92 68 13 50 (0,34?/mn)




Reply via email to