无法在Drupal 6主题中引用css文件来格式化表

时间:2011-12-21 08:32:13

标签: php css drupal-6 drupal-theming

我一直在尝试将css应用到我的Drupal页面,但我确实没有反映这些变化。 以下是我的页面(仪表板页面)http://www.image-share.com/ijpg-1145-262.html的屏幕截图。我的目的是格式化表格列表以显示10行 一段时间,以便表格可滚动查看所有行(而不是它现在如何遍布整个页面)。 下面给出的是代码。

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;

}

我已经将css类提到了$ form ['table']元素的代码中。  我尝试使用css包含:

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

css文件位于'C:\ xampp \ htdocs \ drupalTheme \ sites \ all \ modules \ freeway_module \ css'。  以下是css文件中的代码。

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

但我仍然认为代码无法访问css文件。我包含文件是否正确?期待您的建议。

由于 安吉拉。

2 个答案:

答案 0 :(得分:0)

尝试使用CSS的绝对路径而不是相对路径。只需确定CSS文件在服务器上的确切位置并指向它......然后,您可以回溯并找出相对路径应该是什么。

答案 1 :(得分:0)

  1. 禁用任何CSS / JS缓存。
  2. (下载和)启用devel模块。
  3. 将您的drupal_add_css()电话改为以下内容:
  4. $path = drupal_get_path('module', 'freeway_module');
    dpm($path . '/css/dashboard_file.css');
    drupal_add_css($path . '/css/dashboard_file.css');
    
    1. 清空Drupal缓存只是为了确保。
    2. 检查HTML源代码,或者使用类似Firebug的内容来查看是否包含了CSS。 Firebug还应该告诉你为什么你的CSS无法正常工作,以便正确包含它。
    3. 祝你好运!