from template region to locateblock (navigation)

Nando's Avatar

Nando

17 May, 2016 03:26 AM

Our department site's sub navigation was originally defined in a template region with a custom index block and general format... instead of a region I would like to display it through an all encompassing format. I've already set up a way to dynamically find the custom index block by using the currentpage as a starting point - its what to do after I locate the block that is the problem...

I've attached our current nav format (which HH help us with if not not totally did for us when we first got the system) so its hard for me to follow...

I know when using the locateblock tool we have to use Cascade API - I don't know even know where to start to try to convert the old format to use Cascade API syntax or if its possible... should we just start over?

Any help would be greatly appreciated!

  1. 1 Posted by Wing Ming Chan on 17 May, 2016 02:14 PM

    Wing Ming Chan's Avatar

    Hi Nando,

    The problems you are trying to solve are really complex. So let us disentangle them and look at them one by one.

    1. You have to understand the difference between using indexing and the Locator Tool. With the Locator Tool, you don't have block XML to work with anymore, at least not yet. This is particularly true with respect to index blocks, because even if you can locate an index block, you will have no block XML to work with. The only choice you have (but see below!) is to start with $currentPage and look around. That is to say, if you start with the current page, you have to go through the Cascade API, get the parent folder, and examine each of its children, one by one, and determine what to do with them. They are all Cascade API objects, and there is no more selectNodes or selectSingleNode, or getChild or getChildren. Instead, you'll have getChildren (of a FolderAPIAdapter object), getStructuredDataNodes, getStructuredDataNode, and getMetadata. You will need to tackle the Cascade API directly. It sounds like you don't feel too comfortable with Velocity. If this is the case, then don't even start with the Locator Tool because it is harder than handling block XML.

    2. By "all encompassing format", I believe that you are talking about the format attached to the DEFAULT region (what I call the default format). A large format can be hard to maintain. You can abstract out reusable code and put it somewhere else and keep the default format small. Division of labor. Although my default format processes all the data nodes, produces the page layout, the breadcrumbs, and the left navigation, there are only 430 lines in the format.

    3. It is a mistake to think that you can either use $contentRoot, or the Locator Tool, but not both. In fact, within the context of the default format, you can have both. From the index block calling-page, you can have the information of the parent folder, of all the siblings of the current page, and even of all the descendants of the siblings, all in the block XML. But of course you can also use the Locator Tool here. In fact, I have to use both in my default format to solve the index cache problem.

    4. It is not correct to think that without regions, you cannot have block-format pairs. I can use an instruction block, containing 1) a block to be processed, and 2) a script block, containing format information (the format required to process the block), to replace a region, attach the instruction block to a block chooser in a page, and yet the default format does not really process the instruction block. But again, this requires a thorough understanding of Velocity before terms like instruction blocks and script blocks will ever make sense.

    5. You definitely need to understand the Velocity code you attached. But watch out for lines that do not really do anything. It also seems that you are dealing with a very complicated nav system, and a lot of crucial information is missing from the attached XML file. It is definitely possible to build the nav system, with the availability of both block XML and the Cascade API. Understanding the format you already have is a start.

    You may want to look at my Velocity Tutorial for ideas, for explanations on terms like instruction blocks, and for the Cascade API documentation.

    One more thing. Will you be interested in a series of Google hangouts, like those I have been doing with web services, and talk about Velocity?

    Wing

  2. 2 Posted by Nando on 17 May, 2016 02:38 PM

    Nando's Avatar

    I've used both indexing and the Locator Tool before, in the same format and separate - I'm just not familiar with attached format enough to painlessly convert it to use to Cascade API.

    I've attached blocks to pages before used similar formats but I need to find the nav blocks dynamically so I must use the Locate Tool.

    Your instructions blocks idea is great and I already see where I can use it but not for this.

    I'm going to clean up the current format and remove all the code not being used and go from there...

    Thanks

  3. 3 Posted by Nando on 17 May, 2016 02:39 PM

    Nando's Avatar

    I'm also going to have to take you up on your Google hangouts offer one day soon, thanks again.

  4. 4 Posted by Wing Ming Chan on 17 May, 2016 03:03 PM

    Wing Ming Chan's Avatar

    Please help me understand why you must use the Locator Tool. To start with, the nav blocks are index blocks, right? If they are index blocks, and if you have to use the Locator Tool to find them, then you are stuck, because there are NO methods defined in IndexBlockAPIAdapter to work with indexed content. Simply put, there is nothing you can work with, no XML, no methods.

    Wing

  5. 5 Posted by Nando on 17 May, 2016 03:08 PM

    Nando's Avatar

    How else would I find the index block if not with the locate tool? it's not tied to a region or a page... I dont want it tied to a region and/or page.

    I've attached an index block to a page (with a block chooser) and retrieved the data - I'm thinking along the same route - locate index block and use cascade api to retrieve data...

    if you're free, I can contact you on hangouts directly now - what is your gmail?

  6. 6 Posted by Wing Ming Chan on 17 May, 2016 03:16 PM

    Wing Ming Chan's Avatar

    Send me an email to my work place (which can be found at http://conference.hannonhill.com/2015/java-jsp-velocity.php) and I can give you my gmail address.

    Wing

  7. 7 Posted by Nando on 20 May, 2016 01:57 PM

    Nando's Avatar

    thanks for the 1 on 1s Wing!

  8. Nando closed this discussion on 20 May, 2016 01:57 PM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac