AnsweredAssumed Answered

How can I make a breadcrumb in Surf?

Question asked by darryl_staflund on Aug 18, 2009
Latest reply on Sep 29, 2009 by lingling
Hi all,

Does anybody have any recommendations on how I can create a breadcrumb in Surf?  I am developing a website with a traditional tree-like structure and I had originally decided on adopting the following strategy for building a breadcrumb at the top of my pages (NB:  The following is just pseudocode):


    var breadcrumbs = [];

    function buildBreadcrumb (page) {
         if page == null
             return;
         else
             breadcrumbs.push (page);
             buildBreadcrumb (page.parent);
    }

    return breadcrumbs.reverse ();

In order to get this working, I need to be able to associate child pages with their parent (not the other way around.)  This doesn't seem to be easy to do in Surf though.  Originally I had tried to create page associations with 'child' relations as follows:


    <page-association>
        <source-id>child_page</source-id>
        <dest-id>parent_page</dest-id>
        <assoc-type>parent</assoc-type>
    </page-association>

and then use a Javascript function of the following form:


    sitedata.findPageAssociations('child_page', 'parent');

but no such function exists.  The closest I could find was:


    sitedata.findPageAssociations('child_page', 'parent_page', 'parent');

The problem, though, is that it is precisely the parent page I am trying to identify.

Any ideas on how I might be able to do this?

Thanks,
Darryl

Outcomes