Forum OpenACS Development: Listbuilder and html

Collapse
Posted by Jade Rubick on
I'd like to set my own background colors in listbuilder.

You can do this by doing the following:

        title {
            label "Subject"
            display_template {
                <a href="@tasks.item_url@">@tasks.title@</a>
            }
            html {
                style "background-color: yellow;"
            }
        }

However, what I'd like to do is to make the background color be determined by the value of @tasks.status@ (or $tasks(status)  ).

The html section does seem to have limited access to Tcl variables. Or it tries to. If I put...

        title {
            label "Subject"
            display_template {
                <a href="@tasks.item_url@">@tasks.title@</a>
            }
            html {
                title @tasks.title@
                style "background-color: yellow;"
            }
        }

(obviously this is just a test), however, I get an error, saying $tasks(title) is not defined.

Any other ideas? I'd really like to be able to use color/shading as a UI element.

Collapse
2: Re: Listbuilder and html (response to 1)
Posted by Dave Bauer on
Jade,

The trick is that you can set variables per-row in the db_multirow, so you setup an extended column to hold the information for each row. You can do the calculation in the db_multirow code block.

Specifically for setting colors you can use CSS, of course. There are two options. You can set a "sub_class" which will append the subclass name to the class defined for the entire list, or just define the class name to use explicitly.

This way, you can define the classes semantically, just in case you decide later that the color should be different for a certain class, you can change it in the CSS file.

See template::list::element::create

Collapse
3: Re: Listbuilder and html (response to 1)
Posted by Jeff Lu on
Also aside from setting class and subclass for the elements.
You can also try creating your own list template style.
Just copy the default listtemplate found in packages/acs-templating/resource/lists/
and edit it from there.

Another thing you can do is something similar to this:

display_template {
  <if @tasks.status@ odd>
                <a class ="odd" href="@tasks.item_url@">@tasks.title@</a>
  </if>
  <else>
                <a class ="even" href="@tasks.item_url@">@tasks.title@</a>
  </else>
}

Collapse
4: Re: Listbuilder and html (response to 1)
Posted by Jade Rubick on
Thank you for your suggestions:

The problem with using the display_template section is that using I can't set the class of the surrounding TD or TR. So setting the class will look funny and won't get the entire cell or row.

I'm not sure about making my own customized list-template.

Lars replied privately, and said: "you could add a 'sub_class_eval' property similar to the other eval properties. Not sure what else to do."

The problem with doing this is that then project-manager will be dependent on HEAD.

Any other ideas?