Some time we not able to print value of taxonomy in *.tpl.php page. We can easily print value of a field.
Example
<?php print $node->field_status_icon[$node->language][0]['value']; ?>
When we do same thing for taxonomy, we found blank content. For taxonomy we can fetch data through simple sql code.
Example
<?php $result = db_query("select * from taxonomy_term_data
where tid='".$node->field_type['und'][0]['tid']."'");
foreach($result as $record)
{
echo $record->name;
}?>
Complete Code:
Page—<page name> .tpl.php
<div
class="event_page_mid">
<div class="eventext" >
<?php if($node->field_type['und'][0]['tid']): ?>
<div class="field field-type-options-select field-field-type">
<h3 class="field-label">Type</h3>
<div class="field-items">
<div class="field-item"><?php
$result = db_query("select * from taxonomy_term_data where tid='".$node->field_type['und'][0]['tid']."'");
foreach($result as $record)
{
echo $record->name;
}
?><?php //print $node->field_type['und'][0]['tid']; ?></div>
</div>
</div>
<?php endif; ?>
<?php if($node->field_genre['und'][0]['tid']): ?>
<div class="field field-type-options-select field-field-type">
<h3 class="field-label">Genre</h3>
<div class="field-items">
<div class="field-item">
<?php
$resultterm = db_query("select * from taxonomy_term_data where tid='".$node->field_genre['und'][0]['tid']."'");
foreach($resultterm as $recordnew)
{
echo $recordnew->name;
}
?>
<?php //print $node->field_genre['und'][0]['tid']; ?></div>
</div>
</div>
<?php endif; ?>
<div class="eventext" >
<?php if($node->field_type['und'][0]['tid']): ?>
<div class="field field-type-options-select field-field-type">
<h3 class="field-label">Type</h3>
<div class="field-items">
<div class="field-item"><?php
$result = db_query("select * from taxonomy_term_data where tid='".$node->field_type['und'][0]['tid']."'");
foreach($result as $record)
{
echo $record->name;
}
?><?php //print $node->field_type['und'][0]['tid']; ?></div>
</div>
</div>
<?php endif; ?>
<?php if($node->field_genre['und'][0]['tid']): ?>
<div class="field field-type-options-select field-field-type">
<h3 class="field-label">Genre</h3>
<div class="field-items">
<div class="field-item">
<?php
$resultterm = db_query("select * from taxonomy_term_data where tid='".$node->field_genre['und'][0]['tid']."'");
foreach($resultterm as $recordnew)
{
echo $recordnew->name;
}
?>
<?php //print $node->field_genre['und'][0]['tid']; ?></div>
</div>
</div>
<?php endif; ?>
No comments:
Post a Comment