Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 959175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T00:58:59+00:00 2026-05-16T00:58:59+00:00

I am trying to add custom images into Drupal’s calendar view by checking ‘nid’

  • 0

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:

alt text http://img201.imageshack.us/img201/3140/calendarproblem.png

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; 

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T00:59:00+00:00Added an answer on May 16, 2026 at 12:59 am

    Calendar’s pretty silly. What’s occurring is that the calendar view is creating an ID based on all available fields in the view and stringing them together to create a unique ID. Great in theory, but it assumes a lot (like you not doing what you’re trying to do here).

    You can see what it’s attempting to do in template_preprocess_calendar_node() in theme/theme.inc. The solution is to create your own preprocess function, mytheme_preprocess_calendar_node(&$vars), and set $vars['fields']['id'] to something more sane, like perhaps 'calendar-' . $vars['node']->nid.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to add a custom view control to a custom UITableViewCell which
I am trying to add a second image into my custom dialog but I
I am trying to add custom icons to a Shared Add-in for Microsoft Word.
I'm creating a custom WP theme and trying to add custom menus to the
I am trying to add some custom build steps to my headless build process
I'm trying to add a custom font as a resource in my application. I
I'm trying to add a custom property which is a guid, but it gives
I am trying to add a custom property to a base form that can
I'm trying to add a custom filter to my RadGrid. I have a column,
I am trying to add a custom route to my RESTful routes using the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.