``Context sensitive'' table cells
Hi, I'm just starting with Zope, (as a lot of other folk around here, it seems) and I'm a bit ovewhelmed (same again :) Anyways, I'm in love, in just a few hours and just using <dtml-var ...> I built a (skeleton) site that I'd never would have considered even starting using straight html or something else less powerful. Again, as a lot of other people seem to be doing these days, I built a menu structure using tables. I'd like to have the background color of the cell that has been selected to change to a different color, to reflect where in the site you are at the moment. I came up with the ``code'' below: [ ... Table header ... ] <tr align=center> <td <dtml-if "title == 'Título'"> bgcolor=<dtml-var bgcurrent> <dtml-else> bgcolor=<dtml-var bgmenu> </dtml-if>> <a href="/ABMEC/Consulta/Titulo"> Título </a> </td> </tr> <tr align=center> <td <dtml-if "title == 'Autor'"> bgcolor=<dtml-var bgcurrent> <dtml-else> bgcolor=<dtml-var bgmenu> </dtml-if>> <a href="/ABMEC/Consulta/Autor"> Autor </a> </td> </tr> [ ... Lots of nearly identical rows ... ] </table> In the index_html documento in each folder mentioned in the anchor tag, I have set the title to the string I'm using the comparison. This seems to work (as long as I have unique titles! (not really that bad, as a matter of fact, but not really nice, either)). Clearly, all those repeated if's are something that would go, with a more conventional programming language, into a subroutine or macro or whatever. I tried to create a DTML method to encapsulate it, but I couldn't figure out how to pass to it the argument I wanted the title to be compared to. I think perhaps I'm still locked into a too conventional mindset (my being primarily a fortran programmer and all :) So, I'd like to ask if there is a nicer cleaner way of doing what I wanted to in the first place (ie, changing the background color of one particular table cell depending on which folder is being currently viewed), or alternatively how can I write a DTML method with an argument, to avoid repeating all those <dmtl-if>'s. Many thanks, Ramiro. PS: Thanks for making everything 8 bit clean :) Sorry if this is too simple minded, I did try a lot on my own before asking. -- Ramiro || rbw@demec.ufpe.br
Ramiro Brito Willmersdorf wrote:
So, I'd like to ask if there is a nicer cleaner way of doing what I wanted to in the first place (ie, changing the background color of one particular table cell depending on which folder is being currently viewed), or alternatively how can I write a DTML method with an argument, to avoid repeating all those <dmtl-if>'s.
Assign each of the table cells an ID, and your TABLE a class (navbar). Then, if you do a site wide css-sheet, add this inside the <HEAD> of your standard_html_footer: <dtml-var style_sheet> and style sheet would look something like this: <STYLE TYPE="text/css"> <!-- /* Hide content from old browsers */ .navbar TD { background-color: orange; } <dtml-if here_css><dtml-var here_css></dtml-if> /* end hiding */ --> and then in your here_css, which goes in the folder you want to be the "titulo" section. TD#Titulo { background-color: blue; } So, this would make the background chage from orange to blue when you were in the right area. In fact, I think I'll go implement this on my site :-) -- mindlace Disclaimer: Any use of this email, in any manner whatsoever, will increase the amount of disorder in the universe. Although no liability is implied herein, the reader is warned that this process will ultimately lead to the heat death of the universe.
Ethan Fremen wrote:
Assign each of the table cells an ID, and your TABLE a class (navbar). Then, if you do a site wide css-sheet, add this inside the <HEAD> of your standard_html_footer:
Err- in standard_html_header, of course. -Ethan.
Ramiro Brito Willmersdorf writes:
[···]
Again, as a lot of other people seem to be doing these days, I built a menu structure using tables. I'd like to have the background color of the cell that has been selected to change to a different color, to reflect where in the site you are at the moment. I came up with the ``code'' below: [···] In the index_html documento in each folder mentioned in the anchor tag, I have set the title to the string I'm using the comparison. [···] So, I'd like to ask if there is a nicer cleaner way of doing what I wanted to in the first place (ie, changing the background color of one particular table cell depending on which folder is being currently viewed), or alternatively how can I write a DTML method with an argument, to avoid repeating all those <dmtl-if>'s.
I tried something similar, I changed a title graphic with a method: Method "Title": [··· Table with the titlegraphic ···] <td colspan="1"><img src="gfx/<dtml-var thema>.gif" width="221" height="37"></td> [···] On my pages I insert the title-table with: [···] <!--#call "REQUEST.set('thema','Links')"--> <dtml-var Titel> [···] I think you can adapt this. To the Gurus: How has the call to look? I tried a bit but I´m too new to dtml and Zope. Carsten.
participants (3)
-
Carsten Wartmann -
Ethan Fremen -
Ramiro Brito Willmersdorf