[Q] Generating a dynamic navigation bar...
Background: I have a folder with various DTML Documents and sub-folders in it. Sort of like: /foo/index_html /foo/buy_html /foo/really_buy_html /foo/really_really_buy_html /foo/bar/ I am in the process of writing a DTML method to be used from each of these DTML documents which will generate a dynamic tabbed navigation bar for the other DTML Documents AND sub-folders in this folder. I am envisioning a short table across the width of the page with cells containing links to the other DTML documents and sub-folders. This is what I have so far: <TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0 WIDTH="100%"> <TR> <!--#in "objectItems(['DTML Document','Folder'])"--> <!--#if "AUTHENTICATED_USER.has_permission('View',_.getitem('id',1))"--> <!--#if "title != ''"--> <TD BGCOLOR="#99CCCC" ALIGN=CENTER VALIGN=TOP> <a href="<!--#var "absolute_url()"-->"><!--#var title--></a> </TD> <!--#/if--> <!--#/if--> <!--#/in--> </TR> </TD> </TABLE> Questions: 1. The problem with this DTML method is that all the DTML Documents and Folders are represented as a link in the nav bar. I want to build intelligence into this DTML method to make the tab / cell for the current document just textual (as opposed to a link). If I am calling this method from foo_html, I do not the "tab" for foo_html to be a link. How do I do this? I'm guessing some kind of #if. 2. Currently, the TD cells of the table vary in length based on the contents of the cell. I want all the TDs to be of equal length. I want to first count the number of DTML Documents and Folders and make each TD to be width 100/n % (where n is the number of Documents and Folders). Any ideas on how I can do math inside DTML methods? Thanks. Thaths -- Lisa: It's full, Dad, that means you have to take out the trash. Bart: Yup, that's the rule. "He who tops it off, drops it off." Homer: Nuh-uh. "It isn't filled until it's spilled." Sudhakar C13n http://www.aunet.org/thaths/ Lead Indentured Slave
Hi Sudhakar ! Sudhakar Chandra wrote:
Questions:
1. The problem with this DTML method is that all the DTML Documents and Folders are represented as a link in the nav bar. I want to build intelligence into this DTML method to make the tab / cell for the current document just textual (as opposed to a link). If I am calling this method from foo_html, I do not the "tab" for foo_html to be a link. How do I do this? I'm guessing some kind of #if.
First you can store the your url: <dtml-call "REQUEST.set('my_url', absolute_url())"> Then, when you call your method, you can test whether your url is the current url <dtml-if "absolute_url()==my_url"> The must be another way of doing this, but I can't remember. Does someone else see how this could be done differently ?
2. Currently, the TD cells of the table vary in length based on the contents of the cell. I want all the TDs to be of equal length. I want to first count the number of DTML Documents and Folders and make each TD to be width 100/n % (where n is the number of Documents and Folders). Any ideas on how I can do math inside DTML methods?
You can set a REQUEST variable with the result of your computation: <dtml-call "REQUEST.set('width', 100 / _.len(objectIds(['DTML Document','Folder'])))"> Regards, Maik Röder -- Uzopia - Digging la vida Zopa - http://uzopia.editthispage.com
Maik Roeder proclaimed:
Sudhakar Chandra wrote:
Questions: 1. The problem with this DTML method is that all the DTML Documents and Folders are represented as a link in the nav bar. I want to build intelligence into this DTML method to make the tab / cell for the current document just textual (as opposed to a link). If I am calling this method from foo_html, I do not the "tab" for foo_html to be a link. How do I do this? I'm guessing some kind of #if.
First you can store the your url:
<dtml-call "REQUEST.set('my_url', absolute_url())">
Then, when you call your method, you can test whether your url is the current url
<dtml-if "absolute_url()==my_url">
The must be another way of doing this, but I can't remember. Does someone else see how this could be done differently ?
Thanks. It took a bit of hackage on my part because I was calling the subcategories DTML Method like so: <!--#with aq_parent--> <!--#var subcategories--> <!--#/with--> As you can see, I'm in a different name space inside the DTML method. I put in the REQUEST.set in the main DTML Document instead of the DTML method and it worked like a charm. Only pain now is that all my DTML Documents now need to have the REQEST.set directive in them. Not a big deal.
2. Currently, the TD cells of the table vary in length based on the contents of the cell. I want all the TDs to be of equal length. I want to first count the number of DTML Documents and Folders and make each TD to be width 100/n % (where n is the number of Documents and Folders). Any ideas on how I can do math inside DTML methods? You can set a REQUEST variable with the result of your computation: <dtml-call "REQUEST.set('width', 100 / _.len(objectIds(['DTML Document','Folder'])))">
This worked like a charm. Thanks! S. -- Lisa: It's full, Dad, that means you have to take out the trash. Bart: Yup, that's the rule. "He who tops it off, drops it off." Homer: Nuh-uh. "It isn't filled until it's spilled." Sudhakar C13n http://www.aunet.org/thaths/ Lead Indentured Slave
participants (2)
-
Maik Roeder -
Sudhakar Chandra