css__tableRowClass

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

css__tableRowClass

Postby wisni1rr » Wed Mar 28, 2012 9:38 am

I'm new to the web development scene.

I'm looking to use this function to change the color of a field based on the value of it. For example if the value is "STOP" then it would format the text red or if it's "GO" then it would format green.

My question is where do I put my actual css at to begin with?

Thanks
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: css__tableRowClass

Postby shannah » Wed Mar 28, 2012 9:46 am

You need to include your own stylesheet. What I often do is use the addHeadContent() method of the Dataface_Application object. I place a call to this inside the beforeHandleRequest() method of the application delegate class.
http://xataface.com/dox/core/trunk/clas ... 5046c375b1

Code: Select all
function beforeHandleRequest(){
    $app = Dataface_Application::getInstance();
    $app->addHeadContent('<link rel="stylesheet" type="text/css" href="mystyles.css"/>');
}


In this case you would add a file named mystyles.css to your application's directory and add your own custom CSS in there.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: css__tableRowClass

Postby wisni1rr » Wed Mar 28, 2012 10:09 am

I've added your call to my ApplicationDelegate.php.

I have created a file, "mystyles.css" with this content:

Code: Select all
<html>
<style>
tr.ACT td {color:green;}
tr.PEN td {color:orange;}
tr.CLO td {color:red;}
</style>
</html>

My table delegate contains this:
Code: Select all
    function css__tableRowClass( &$record ){
        if ( $record->val('Status') == "ACTIVE" ) return 'ACT';
        else return 'PEN';
    }


However, nothing changes is my list view.
Any Ideas?
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: css__tableRowClass

Postby shannah » Wed Mar 28, 2012 11:09 am

The content of those cells are probably links (i.e. "a" tags) so their style is probably overriding the text style assigned to the td tag.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: css__tableRowClass

Postby wisni1rr » Wed Mar 28, 2012 11:22 am

Would my desired result be best handled by using the renderCell method instead?

I just need to format the color of the text of a field in list view based on the value of its contents.
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: css__tableRowClass

Postby shannah » Wed Mar 28, 2012 11:33 am

You can handle it any way you like. I was just pointing out that your CSS targets the td tag. But you should probably also target the a tags within the td tags.
Code: Select all
tr.ACT td, tr.ACT td a {color:green;}
tr.PEN td, tr.PEN td a {color:orange;}
tr.CLO td, tr.CLO td a {color:red;}



I now also notice that you had html tags in your CSS files. You don't need to put html tags (e.g. <html> <style> etc..) inside the CSS file. In fact this will cause it to break.

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: css__tableRowClass

Postby wisni1rr » Wed Mar 28, 2012 12:07 pm

Yes, they are links. I forgot to answer this in my last post. I have tried to add style to the "a" tags as you have described but I still do not see a change. The cells are all still the light blue link color.
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm

Re: css__tableRowClass

Postby shannah » Wed Mar 28, 2012 12:10 pm

Did you still have the HTML markup in your stylesheet? CSS requires trial and error sometimes. Make sure that
1. Your stylesheet is being picked up. (e.g. make some crazy and easy style rules that will let you know if they are working).
2. Your particular rule is being picked up (try adding !important to some rules to make sure they can't be overridden by other rules).

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: css__tableRowClass

Postby wisni1rr » Wed Mar 28, 2012 12:37 pm

I'm thinking that by css is not getting pulled. My page source looks like this:

Code: Select all
         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
      <title>Omitted</title>
      <link rel="stylesheet" type="text/css" href="http://bwaxatatest.elementfx.com/xataface/plone.css"/>      <!-- Stylesheets go here -->      
            <!-- Common Plone ECMAScripts -->
wisni1rr
 
Posts: 107
Joined: Mon Feb 13, 2012 9:03 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 3 guests

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