I am trying to add custom images into Drupal's calendar view by checking 'nid' of a node (or taxonomy term in future). I am writing this custom code in views-view-field--calendar--nid.tpl.
The problem is that, what ever is output by views-view-field--calendar--nid.tpl is also inserted into 'id' attribute of div tag. Please see the second div tag.
254 was the output and it is also inserted into 'id' attribute.
<div class="view-item view-item-calendar">
<div class="calendar monthview" id="calendar:
254:changed:0:0">
<div id="nid" class="view-field view-data-nid">
254 </div>
</div>
So when views-view-field--calendar--nid.tpl outputs img tag, it also get inserted into 'id' attribute, which breaks the second div tag.
Please, see following output
<div class="view-item view-item-calendar">
<div class="calendar monthview" id="calendar:
<img src="http://www.programmingnature.com/stackoverflow_32.png"> </img>255:changed:0:1">
<div id="nid" class="view-field view-data-nid">
<img src="http://www.programmingnature.com/stackoverflow_32.png"> </img>255 </div>
</div>
</div>
Screenshot:
Please note that Calender view tried to insert the output with img tag inside that 'id' attribute and everything now is messed up...
How can I prevent Calender from inserting output into 'id' attribute? Or is there any alternative way to insert images in Calender view ?
Following is the code of views-view-field--calendar--nid.tpl
<?php
$results = $variables['view']->result;
$nid=$output;
$newOutput="";
foreach ($results as $key => $value) {
//Find the matching nid
if ($nid==255) {
$newOutput.= '<img src="http://www.programmingnature.com/stackoverflow_32.png"> </img>';
}
$newOutput.=$nid;
}
print $newOutput;
?>