2009-12-30 7 views
2

저는 드루팔 (Drupal)보기에서 색상 코딩을 연구하는 방법을 꿈꾸고 있습니다. 나는 이것에 대한 몇 가지 요구를 가지고 있지만 그것을하는 방법을 알아낼 수 없습니다. 다음은 몇 가지 예입니다.드루팔 (Drupal : 컬러 코딩보기

  1. 콘텐츠 형식의 테이블보기에서 게시물의 나이를 기준으로 각 행에 색을 지정하고 싶습니다. 즉, 게시물의 "나이"는 테이블의 열 중 하나이며 게시물이 하루보다 오래 된 각 행을 노란색 배경으로 강조 표시하고 싶습니다. 일주일이 넘으면 빨간색으로 강조 표시하세요.

누구나 아이디어가 있으십니까? 나는 아마 우리가 보통의 웹 페이지에서 조건부 값을 잡을 수 있다고 생각하지만, 이것은 드루팔 (Drupal)에서 까다로울 뿐이다. 그리고 자바 스크립트 지식은 제한적이다. 나는 좋은 ole SQL을 사용하여 값에 대한 PHP를 실행할 수 있고 CSS 선택기를 연관시킬 수 있지만 뷰 (기여한 modlue)에서이를 수행하려고합니다. 미리 감사드립니다.

+0

예를 들어, 어떻게 테이블을 생성합니까? 템플릿 (tpl.php) 파일을 사용하고 있습니까? 또는 다른 모듈을 사용합니까? – dusan

+0

보기 모듈 - SQL 작성에 신경 쓰지는 않지만 뷰의 유연성을 좋아합니다. 인수, 블록, 쉬운 아약스 등. – tpow

답변

1

Temp.tpl.php (Temp는 뷰 이름 임) 뷰를 생성하여 날짜에 따라 클래스에 삽입합니다. 다음은 생성 된 날짜를 Time Ago로 변경하고 stripos로 Week 또는 Day를 검색 한 예제입니다. php date math 또는 다른 메소드를 사용하여 클래스를 삽입 할 수 있습니다. 이것은 매우 기본적이고 조정이 필요합니다.

<?php 
// $Id: views-view-table.tpl.php,v 1.8 2009/01/28 00:43:43 merlinofchaos Exp $ 
/** 
* @file views-view-table.tpl.php 
* Template to display a view as a table. 
* 
* - $title : The title of this group of rows. May be empty. 
* - $header: An array of header labels keyed by field id. 
* - $fields: An array of CSS IDs to use for each field id. 
* - $class: A class or classes to apply to the table, based on settings. 
* - $row_classes: An array of classes to apply to each row, indexed by row 
* number. This matches the index in $rows. 
* - $rows: An array of row items. Each row is an array of content. 
* $rows are keyed by row number, fields within rows are keyed by field ID. 
* @ingroup views_templates 
*/ 
?> 
<table class="<?php print $class; ?>"> 
    <?php if (!empty($title)) : ?> 
    <caption><?php print $title; ?></caption> 
    <?php endif; ?> 
    <thead> 
    <tr> 
     <?php foreach ($header as $field => $label): ?> 
     <th class="views-field views-field-<?php print $fields[$field]; ?>"> 
      <?php print $label; ?> 
     </th> 
     <?php endforeach; ?> 
    </tr> 
    </thead> 
    <tbody> 
    <?php foreach ($rows as $count => $row): ?> 
     <tr class="<?php print implode(' ', $row_classes[$count]); ?> <?php 
     if(stripos($row["created"], "Week")) { 
       print "week-class "; 
     } 
     if(stripos($row["created"], "Day")) { 
       print "day-class "; 
     }?> 
     "> 
     <?php foreach ($row as $field => $content): ?> 
      <td class="views-field views-field-<?php print $fields[$field]; ?>"> 
      <?php print $content; ?> 
      </td> 
     <?php endforeach; ?> 
     </tr> 
    <?php endforeach; ?> 
    </tbody> 
</table> 
+0

아직 테스트하지는 않았지만 로직이 올바르다. 감사 – tpow