Pesquisa
Itens ativos
Posts mais lidos hoje
Login do usuário
Assine o RSS do Drupal-BR
Puxar ID de termo da taxonomy
Olá,
Estou com um problema, criei uma views aonde ela vai puxar 3 categorias, de várias categorias cadastrada na taxonomy. Só que cada categoria nessa views vai ter que receber um estilo diferente uma da outra, por exemplo: categoria Educação - tem a cor preto, categoria Metodologia Cientifica - tem a cor azul e assim em diante. Como eu faço para puxar o ID desta categoria e colocar no arquivo da views.
abaixo código.
<div class="block block-views" id="block-views-destaque_catalogo-block_1"> /*AQUI ESTÁ CHAMANDO O BLOCO DESTAQUE CATALOGO*/
<div class="content">
<div class="view view-destaque-catalogo view-id-destaque_catalogo view-display-id-block_1 views-processed">
<div class="view-content">
<div class="views-field-name">/*AQUI PRECISO COLOCAR O ID DA CATEGORIA DA TAXONOMY*/
<span class="field-content"><a href="/editoraibpex/?q=taxonomy/term/11">Metodologia Científica</a> - name</span>
</div>
<div class="views-field-description">/*AQUI PRECISO COLOCAR O ID DA CATEGORIA DA TAXONOMY*/
<span class="field-content"><p>Metodologia Científica</p></span>
</div>
</div>
</div>
</div>
<div class="content">
<div class="view view-destaque-catalogo view-id-destaque_catalogo view-display-id-block_1 views-processed">
<div class="view-content">
<div class="views-field-name">/*AQUI PRECISO COLOCAR O ID DA CATEGORIA DA TAXONOMY*/
<span class="field-content"><a href="/editoraibpex/?q=taxonomy/term/11">Metodologia Científica</a> - name</span>
</div>
<div class="views-field-description">/*AQUI PRECISO COLOCAR O ID DA CATEGORIA DA TAXONOMY*/
<span class="field-content"><p>Metodologia Científica</p></span>
</div>
</div>
</div>
</div>
Preciso que nessa class views-field-name e views-field-description seja acrescentado o id da categoria que está chamando por exemplo views-field-description-"11"?
O código da página views é
<?php
// $Id: views-view-fields.tpl.php,v 1.5 2008/05/05 23:51:47 merlinofchaos Exp $
/**
* @file views-view-fields.tpl.php
* Default simple view template to all the fields as a row.
*
* - $view: The view in use.
* - $fields: an array of $field objects. Each one contains:
* - $field->content: The output of the field.
* - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
* - $field->class: The safe class id to use.
* - $field->handler: The Views field handler object controlling this field. Do not use
* var_export to dump this object, as it can't handle the recursion.
* - $field->inline: Whether or not the field should be inline.
* - $field->inline_html: either div or span based on the above flag.
* - $field->separator: an optional separator that may appear before a field.
* - $row: The raw result object from the query, with all data it fetched.
*
* @ingroup views_templates
*/
?>
<?php foreach ($fields as $id => $field): ?>
<?php if (!empty($field->separator)): ?>
<?php print $field->separator; ?>
<?php endif; ?>
<<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
<?php if ($field->label): ?>
<label class="views-label-<?php print $field->class; ?>">
<?php print $field->label; ?>:
</label>
<?php endif; ?>
<span class="field-content"><?php print $field->content; ?></span>
</<?php print $field->inline_html;?>>
<?php endforeach; ?>
// $Id: views-view-fields.tpl.php,v 1.5 2008/05/05 23:51:47 merlinofchaos Exp $
/**
* @file views-view-fields.tpl.php
* Default simple view template to all the fields as a row.
*
* - $view: The view in use.
* - $fields: an array of $field objects. Each one contains:
* - $field->content: The output of the field.
* - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
* - $field->class: The safe class id to use.
* - $field->handler: The Views field handler object controlling this field. Do not use
* var_export to dump this object, as it can't handle the recursion.
* - $field->inline: Whether or not the field should be inline.
* - $field->inline_html: either div or span based on the above flag.
* - $field->separator: an optional separator that may appear before a field.
* - $row: The raw result object from the query, with all data it fetched.
*
* @ingroup views_templates
*/
?>
<?php foreach ($fields as $id => $field): ?>
<?php if (!empty($field->separator)): ?>
<?php print $field->separator; ?>
<?php endif; ?>
<<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
<?php if ($field->label): ?>
<label class="views-label-<?php print $field->class; ?>">
<?php print $field->label; ?>:
</label>
<?php endif; ?>
<span class="field-content"><?php print $field->content; ?></span>
</<?php print $field->inline_html;?>>
<?php endforeach; ?>
Qual a tag ou forma para incluir esse ID neste código a cima?
Desde já Obrigado
Enviado por joneldesouza em sex, 26/09/2008 - 11:09.
- Por favor, se logue ou se registre para poder enviar comentários
- 139 leituras




Active Template
Olá, Jonel!
Vc já experimentou o módulo Active Template?? Ele funciona da mesma maneira que o Contemplate, só que é específico para Views.
Com ele você pode descobrir quais são as variáveis e arrays que geram as Views e asim personalizar o template do body, teaser e fields dos nodes exibidos pela View.
Achei que poderia ser útil porque vc pode fazer o seguinte: descobrir qual variável retorna a categoria de cada node exibida na sua view e inserí-la no template da sua view através da ferramenta Import (ou quem sabe até através do próprio Active Template). De maneira que essa variável gere uma ID contendo a categoria de cada node.
Francamente nunca fiz isso mas acho que deve funcionar.
Qualquer coisa grite aqui novamente.
Abç,
Harald Wölfl Essert
http://www.harald.essert.nom.br
Olá Harald, Conseguir
Olá Harald,
Consegui arrumar o problema. Em relação aos módulos que você passou eles não funcionam no drupal 6x, mas obrigado por ter passado.
Neste aquivo da views na linha aonde tem o field->content coloquei a tag <?php print_r ($row); ?>, isso faz com que apareça todos os dados cadastrado na tabela. E na impressão que foi para a tela aparece uns códigos que tem o id, que está sendo chamado por (TID). Após isso coloquei <?php print $row->tid; ?> para que chame o id.
// $Id: views-view-fields.tpl.php,v 1.5 2008/05/05 23:51:47 merlinofchaos Exp $
/**
* @file views-view-fields.tpl.php
* Default simple view template to all the fields as a row.
*
* - $view: The view in use.
* - $fields: an array of $field objects. Each one contains:
* - $field->content: The output of the field.
* - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
* - $field->class: The safe class id to use.
* - $field->handler: The Views field handler object controlling this field. Do not use
* var_export to dump this object, as it can't handle the recursion.
* - $field->inline: Whether or not the field should be inline.
* - $field->inline_html: either div or span based on the above flag.
* - $field->separator: an optional separator that may appear before a field.
* - $row: The raw result object from the query, with all data it fetched. "Uma array com todos os dados de cada item encontrado na tabela."
*
* @ingroup views_templates
*/
?>
<div id="<?php print $row->tid; ?>"> // CHAMA A ID DA CATEGORIA DO TAXONOMY
<?php foreach ($fields as $id => $field): ?>
<?php if (!empty($field->separator)): ?>
<?php print $field->separator; ?>
<?php endif; ?>
<<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>">
<?php if ($field->label): ?>
<label class="views-label-<?php print $field->class; ?>">
<?php print $field->label; ?>:
</label>
<?php endif; ?>
<span class="field-content"><?php print $field->content; ?></span>
</<?php print $field->inline_html;?>>
<?php endforeach; ?>
</div>
Em fim, levou um tempinho mas conseguir. Obrigado pelas dicas. Qualquer coisa estarei a disposição para esplicar melhor isto.