Table-based coloring of UI-elements in view mode

A place for users and developers of the Xataface to discuss and receive support.

Table-based coloring of UI-elements in view mode

Postby christoph » Mon Oct 29, 2012 7:13 pm

Hi all,
I'm looking for a quick and not too complicated way to implement a usability feature. My data model has ca. 25 tables, and I assigned each of these tables an individual color that I'm using consistently in reports, drawings, etc. It really speeds up finding something in a large multi-table report when you only have to look for a particular color instead of having to read column titles. Obviously, I would also like to apply this color scheme to the web interface, i.e. specifically, I would like to automatically set the background color of table titles to the respective table color. One particular set of elements that I would like to color this way are the table selection tabs, and the region just below these tabs (I have them horizontally at the top). Another one are the section top regions of the view page and the collapsible sidebar titles with the related records from other tables (obviously each of them with its own table color).

I was able to implement parts of this. One approach is to define a custom block in every tablename.php, e.g. like this :
Code: Select all
   
function block__before_bread_crumbs(){
    echo"<div style=\"background: #99ccff\"> some text, e.g. the table name </div>";
    }

Another approach is with a calculated field, e.g. like this:
Code: Select all
function field__color($record){
    return '#99ccff';
    }

and then I apply my color by adding
Code: Select all
style="background: {$record->val('color')}
e.g. to the dataface-sections-top-column in the Dataface_View_Record template file.

So, this partly does what I want, but I'm not yet satisfied with my approaches:
1) I have to hardcode all this into the individual tablename.php files or into the templates. It would be nicer to have it in a central location at the global level.
2) More important: I don't currently know a good way to apply my table coloring scheme to the table selection tabs (Dataface_NavMenu) and to the collapsible sidebar titles of related records. Well, I did something for the selection tabs, by adding a hardcoded block of if/elseif conditions to the NavMenu template and to the Main_Template (for the status bar), which defines the right color in function of $table. But that means hardcoded table names in multiple templates; not nice at all.

I assume that this can be done more elegantly by defining/using the right type of global variable (e.g. some array with table name, background color and font color) and then adding/replacing background-color attributes in plone.css and/or NavMenu.html with a function, but I'm stuck right now (I'm quite new to Xataface and neither PHP nor CSS are part of my normal daily business).

Thanks in advance for any input.
christoph
 
Posts: 4
Joined: Fri Oct 26, 2012 4:41 am

Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 2 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved