Friday, July 3, 2015

Page: Placed or Unplaced

There are times when one needs to know if a page asset is under default node or unplaced node of siteplan; be it while generating sitemap, left navigation, top navigation, breadcrumb or finding page asset which contains a particular associated asset.

Mostly anyone can find if a particular page is placed or unplaced using following query:

Select ncode from SitePlanTree where otype='Page' and oid='[Page id]'

But, there seems to be bug for this within Oracle WCS product for the following case. Suppose you have following setup in your siteplan under Default node.

DEFAULT
Page1
- Subpage1
- Subpage2

And if you were to unplace Page1 (along with chilren page assets) from "Default" to "Unplaced Pages" node, ncode for Page1 changes to "Unplaced" but all its children page assets ncode's value remains same i.e. "Placed" as information in SitePlanTree is not updated for children page assets. Hence, running the above query will yield false info.

I faced similar situation when in certain project, there was a requirement to find placed page asset whose association is some asset. As Contributors added that asset to only one placed page asset, it should be unique according to them. But it seemed that somebody had moved that page asset from Default to Unplaced page node which happened to be same case as above and created new set of page asset which was valid as there was only one placed page asset with such association.

Solution: To counter this, there is tag which can decipher if all the parent page assets of a particular page asset are under DEFAULT or UNPLACED node: siteplan:unplacedancestor

<asset:load name="pageAsset" type="Page" objectid='<%=ics.GetVar("PageId")%>'/>
<asset:getsitenode name="pageAsset" output="PageNodeId"/>
<siteplan:load name="pageNode" nodeid='<%=ics.GetVar("PageNodeId")%>'/>
<siteplan:unplacedancestor name="pageNode" output="hasunplacedparent"/>
Parent pages are placed?: <ics:getvar name="hasunplacedparent" />

If value is true, then the loaded page asset is under UNPLACED node.

Disclaimer: Any sample code on this blog is not officially recommended, use at your own risk.

No comments:

Post a Comment

A simple code compare functionality

One of the most important aspect of any development cycle is deployment and while deployment, it is very important to note the changes don...