CCK настройка отображения

Главные вкладки

Аватар пользователя hostsid hostsid 3 мая 2011 в 7:15

Добрый день уважаемое сообщество Smile
Есть проблема. Помогите пожалуйста решить.

Создано поле ССК.
Тип данных: текст.
Элемент редактирования поля: выключатель да/нет.

Когда стоит галочка, в верстке результат отображения таков:

<div class="field field-type-text field-field-tag-1-1">
   <div class="field-label">Заголовок</div>
   <div class="field-items">Текст</div>
</div>

Когда же галочка не стоит:

<div class="field field-type-text field-field-tag-1-1">
   <div class="field-label">Заголовок</div>
   <div class="field-items"> - </div>
</div>

Вопрос: Как сдеть что б в случае, когда галочка не стоит контейнер

вообще не отображался?

Комментарии

Аватар пользователя hostsid hostsid 3 мая 2011 в 15:13

Как выводится?...не совсем понятен вопрос. как обычная нода (создан новый тип содержимого в котором соданы поля благодаря модулю ССК)

В PHP не силен. Подскажите пожалуйста какую проверку и куда ее вставлять?

Аватар пользователя hostsid hostsid 3 мая 2011 в 15:53

Вот нашел шаблон вывода полей ССК:


<?php
// $Id: content-field.tpl.php,v 1.1.2.6 2009/09/11 09:20:37 markuspetrux Exp $

/**
 * file content-field.tpl.php
 * Default theme implementation to display the value of a field.
 *
 * Available variables:
 * - $node: The node object.
 * - $field: The field array.
 * - $items: An array of values for each item in the field array.
 * - $teaser: Whether this is displayed as a teaser.
 * - $page: Whether this is displayed as a page.
 * - $field_name: The field name.
 * - $field_type: The field type.
 * - $field_name_css: The css-compatible field name.
 * - $field_type_css: The css-compatible field type.
 * - $label: The item label.
 * - $label_display: Position of label display, inline, above, or hidden.
 * - $field_empty: Whether the field has any valid value.
 *
 * Each $item in $items contains:
 * - 'view' - the themed view for that item
 *
 * see template_preprocess_content_field()
 */

?>
<?php 
if (!$field_empty) : ?>
<div class="field field-type-<?php print $field_type_css ?> field-<?php print $field_name_css ?>">
  <?php if ($label_display == 'above') : ?>
    <div class="field-label"><?php print t($label?>:&nbsp;</div>
  <?php endif;?>
  <div class="field-items">
    <?php $count 1;
    foreach (
$items as $delta => $item) :
      if (!
$item['empty']) : ?>
        <div class="field-item <?php print ($count 'odd' 'even'?>">
          <?php if ($label_display == 'inline') { ?>
            <div class="field-label-inline<?php print($delta '' '-first')?>">
              <?php print t($label?>:&nbsp;</div>
          <?php ?>
          <?php print $item['view'?>
        </div>
      <?php $count++;
      endif;
    endforeach;
?>
  </div>
</div>
<?php endif; ?>

Теперь вопрос: как вставить проверку в моем случае?

Аватар пользователя hostsid hostsid 3 мая 2011 в 17:50

РЕШЕНО.


<?php if (!$field_empty) : ?>
// Проверяем перебором массива соответствие переменной item view  значению "-"
<?php $preCheck true;
foreach (
$items as $delta => $item) :
    if(
$item['view'] == "-"): 
        
$preCheck false;
        break;
    endif;
endforeach;
// И только если соответствия нет - идет снова обработка массива с выводом
if($preCheck): ?>
<div class="field field-type-<?php print $field_type_css ?> field-<?php print $field_name_css ?>">
  <?php if ($label_display == 'above') : ?>
    <div class="field-label"><?php print t($label?>:&nbsp;</div>
  <?php endif;?>
  <div class="field-items">
    <?php $count 1;
    foreach (
$items as $delta => $item) :
      if (!
$item['empty']) : ?>
        <div class="field-item <?php print ($count 'odd' 'even'?>">
          <?php if ($label_display == 'inline') { ?>
            <div class="field-label-inline<?php print($delta '' '-first')?>">
              <?php print t($label?>:&nbsp;</div>
          <?php ?>
          <?php print $item['view'?>
        </div>
      <?php $count++;
      endif;
    endforeach;
?>
  </div>
</div>
<?php endif; ?>
<?php 
endif; ?>