How to implement a dynamic menu with dependency?
This is a little complicated so we divide this into the following stages:
Create an option model
- Create a block content at the root of your site and give it an anchor as usual
- Edit the block content and create a hierarchy of your data using the un-ordered list, if you look at the source, it should look like the following:
<ul>
<li id="{Option value}">{Option name, first level}
<ul>
<li id="{Option value}">{Option name, second level}
<li id="{Option value}">{Option name, second level}
<li id="{Option value}">{Option name, second level}
</ul>
<li id="{Option value}">{Option name, first level}
<ul>
<li id="{Option value}">{Option name, second level}
<li id="{Option value}">{Option name, second level}
<li id="{Option value}">{Option name, second level}
</ul>
</li>
</ul>
The above data is what we call option model.
Implement your data service
The purpose of this stage is to prepare your data in a hierarchy and let Gecko serve it as a data service.
- Create a new template and let's call it Option Model.
- Remove all other divs except the center div .
- Add a Core:Option xlet to the div while removing all other xlets
- Configure the xlet and point the xlet to point to the option model you created previously by setting the anchor.
- Create a new page in your site and select the "Option Model" template
- Set "Visiable to navigator" to no.
- Update the site and copy the URI of the page. It should look like this: http://216.55.160.187:8888/xpe/portal/95c5e492-10e5-1000-91a2-d7ffb3fd10b5
- Change the above URL to http://216.55.160.187:8888/xpe/portal/xml/95c5e492-10e5-1000-91a2-d7ffb3fd10b5 and copy it. This is what we call your data service address.
Creating dynamic metadata fields
Now you can add data fields to your attribute group.
- Select or create an Attribute Group that you wish to add the data fields
- Add a new attribute as usual and select the ui to "dropdown with dependency"
- Leave the depends field empty for the first attribute
- Paste the data service address to the Model URI field
- Click "Add a new attribute"
- Change the name and description as usual
- Put the name of the first attribute to the "depends" field and submit the form
All done!
Now, the review2 or review xlet is able to take advantage of this new addition. When adding a new content, the dynamic menu will change accordingly.
Examples:
The attribute group:
http://216.55.160.187:8888/xpe/formServer/html?xpf_form_id=xpf_9709390f-10e5-1000-94f8-d7ffb3fd10b5
The review xlet that uses dynamic menu:
http://216.55.160.187:8888/xpe/portal/95ccf8c6-10e5-1000-91f6-d7ffb3fd10b5