简体   繁体   中英

Unable to refer css file in Drupal 6 theme for formatting a table

I have been trying to work with applying css to a Drupal page of mine but the changes i do do not reflect. The following is the screenshot of my page (a dashboard page) http://www.image-share.com/ijpg-1145-262.html . My aim is to format the table listing to show 10 rows at a time so that the table is scrollable to view all the rows (rather than how its spread across the entire page now). The below given is the code.

function freeway_dashboard(){
 drupal_add_css(drupal_get_path('module', 'freeway_module') .'/css/dashboard_file.css');
 //echo(drupal_get_path('module', 'freeway_module') .'/css/dashboard_file.css');
 drupal_add_js(drupal_get_path('module', 'freeway_module') .'/js/dashboardscript.js');

  $listOfProjectsIds = array();
  $listOfProjectsDesc = array();
  $node = node_load(arg(1));
  $form = array();
  $arrayStatus = array(1 =>'Draft',2=>'NotSpecified',3=>'Quote',4=>'Forecasted',5=>'InEvaluation',6=>'Cancelled',7=>'Booked',8=>'InProduction',9=>'Completed',10=>'Closed');


            $LoginClient = new SoapClient("https://freeway.demo.lionbridge.com/vojo/FreewayAuth.asmx?wsdl", array("trace"=>1)); 
            $ServicesLink = new SoapClient("https://freeway.demo.lionbridge.com/vojo/Service.asmx?wsdl", array("trace"=>1));


              try{

              $arrResponse = $LoginClient->Logon(array ('Username'=>'user','Password'=>'Password'));
              $ticket = ($arrResponse->LogonResult);
              $getSrcLang = $ServicesLink->GetSourceLanguages(array('Ticket'=>$ticket));
              $getDraftProjectIds = $ServicesLink->GetProjectSummariesList(array('Ticket'=>$ticket,'NumberOfProjects'=>100,'SortOrder'=>MostRecent,'ProjectStatusCode'=>'Draft'));

                            foreach ($getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary as $i=>$getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary) 
                            {

                             $listOfProjectsIds[$i] = $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary->ID;                     
                             $listOfProjectsDesc[$i] = $getDraftProjectIds->GetProjectSummariesListResult->ProjectSummaries->ProjectSummary->Description;                       
                            } 

              }
                  catch (SoapFault $exception){
                  return $exception;
              }


        $form['status_list']=array(
                '#type'=>'select',
                '#title' => t('Freeway Project Statuses'),
                '#options' => $arrayStatus,
                '#default_value' => ('Draft'),
                '#attributes'=> array('onselect' => "populateStatusTables();"),
                '#weight'=>3,
            );

    $header = array('Project ID', 'Project Description'); 
    $rows = array(); 

    for($m=0;$m <count($listOfProjectsIds);$m+=1){

    $rows[$m] = array($listOfProjectsIds[$m], $listOfProjectsDesc[$m]) ;

    }


    $form['table'] = array( 
     '#value' => theme('table', $header, $rows, array( 'class' => 'table_class','id'=>'dashboard_Table')), 
     //'#value' => '<div class="table_class_wrapper">'. theme('table', $header, $rows, array('class' => 'table_class','id'=>'dashboard_Table')) .'</div>',
    '#weight' => 4, 
    );


    return $form;

}

I have given the css class mention to the code at $form['table'] element in its value. I have tried to use the css inclusion using:

  drupal_add_css(drupal_get_path('module', 'freeway_module') .'/css/dashboard_file.css');

The css file is placed at 'C:\\xampp\\htdocs\\drupalTheme\\sites\\all\\modules\\freeway_module\\css'. The following is the code in the css file.

    .table_class { 
height: 200px; 
overflow: auto; 
}

But still i guess the code is not able to access the css file. Am i including the file correct? Looking forward for your advice.

Thanks Angela.

Try using an absolute path to the CSS rather than a relative path. Just figure out exactly where the CSS file is on the server and point to it... Then, you can backtrack and figure out what the relative path should be.

  1. Disable any CSS/JS caching.
  2. (Download and) Enable the devel module.
  3. Change your drupal_add_css() call to something like the following:
 $path = drupal_get_path('module', 'freeway_module'); dpm($path . '/css/dashboard_file.css'); drupal_add_css($path . '/css/dashboard_file.css'); 
  1. Empty the Drupal cache just to be sure.
  2. Check the HTML source or alternatively, use something like Firebug to see if your CSS is being included. Firebug should also tell you why your CSS is not working in case it is being included correctly.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM