I created a content type called meetup through date tools(date wizard). Date tools created a view and set the path of calendar page as "/calendar-date".

And I add a new meetup content then view the new meetup content I just add.

There's a Calendar link under the content body(next to "Add new comment" link). But the path of the Calendar link is wrong(the path is "/calendar" not "/calendar-date"). is it a bug?

how can I change the path of calendar link or remove it?

Thanks a lot for your precious time.

Files: 
CommentFileSizeAuthor
#8 Picture 24.jpg101.77 KBJohn Bickar

Comments

Title:How can I change or remove the Calendar link under node body?Unable to change or remove the Calendar link under node body
Category:support» bug

This link also appears in 6.x-2.1.

I've had a look through the code, tested something, and I think I know what's going on now, although I don't know how to really fix it.

This is function that is adding the Calendar link to nodes:

<?php
/**
* Add link to calendar to nodes.
*
* Controlled by value of 'calendar_date_link' in the view.
*/
function calendar_link($type, $object, $teaser = FALSE) {
  if (
$type == 'node' && !$teaser) {
   
$path = variable_get('calendar_date_link_'. $object->type, NULL);
    if (!empty(
$path)) {
      return array(
'calendar_link' => array(
       
'title' => t('Calendar'),
       
'href' => $path,
       
'attributes' => array('title' => t('View the calendar.')),
        ));
    }
  }
}
?>

It checks for this variable: 'calendar_date_link_[content_type]' and if it exists, the calendar link gets added to the links section.

That variable is set In the Calendar Page display, "Add New Date link". If you change it, it adds a new variable, but the old variable is not removed from the database.

A workaround for this issue is to delete the calendar_date_link_[content_type] rows from the variables table of the database. Clear Drupal's cache, and the calendar link should be gone.

(To speak to your original question, try this: Remove these variables, then edit the view that presents "/calendar-date" and select your "meetup" content type for "Add New Date link". I think that should link to the correct view now.)

I think that the real solution to the problem would be to fix how the calendar_date_link_[content_type] variable is stored. I suppose that would mean deleting the variables for the other content types when saving "Add New Date link".

Changing this issue to a bug report and updating the title to "Unable to change or remove the Calendar link under node body"

Same problem... subscribing.

same problem

Having the same problem. Tried to add a new calendar page that doesn't show up and assigning this to the link display. The node link stays the same though.

I can confirm that the workaround to remove the link works. Thanks nadavoid

The problem occurs in calendar_plugin_display_page.inc at line 245:

243       case 'calendar_date_link':
244         $this->set_option($form_state['section'], ($form_state['values'][$form_state['section']]));
245   *    variable_set('calendar_date_link_'. $form_state['values']['calendar_date_link'], $this->display->handler->get_option('path'));
246         break;

The variable is set regardless of any previous option settings. Frankly, working around that is going to be pretty evil. The view saves this data row when you click "Update" after selecting the content type to nominate.

Furthermore, this has the appearance of not respecting view permissions - this could be because the path is incorrectly rendered, however, if you have arguments in the path.

If the view path contains arguments, these are not substituted. This will break permission checking, but I can't test that until I find out if I can fix the path...

Edit: Even if that was possible, which I'm not sure, some argument won't make sense on nodes. User arguments for example. Let's say user 2 has created some nodes and those are displayed on a calendar at /user/2/calendar. If user 2 goes to node 123 (which he created, and appears on his calendar) then he would likely want to see the link at the bottom, which would be the same as the previous one.

However, even if user 3, from another role, has permission to look at the view, it doesn't make sense to try and substitute a path of "/user/%/calendar" because the role of user 3 will only see the view at "/user/3/calendar" when the argument it parsed. So... that's nonsense. Agh.

If you want to get rid of the link altogether, here's some code. You need to add this into a module. It can also be done in the theme layer but I personally think this is "business logic"...

<?php
function mymodule_link_alter(&$links, $node) {
  foreach (
$links as $module => $link) {
    if (
strstr($module, 'calendar')) {
     
// remove the broken link back to the calendar - see http :// drupal.org/node/462748#comment-2099126
      // don't know if this breaks any other calendar links?!
     
unset($links[$module]);
    }
  }
}
?>

StatusFileSize
new101.77 KB

nadavoid, thank you for posting this workaround! I was banging my head on this for a bit before the Google led me to this issue.

I have little to contribute besides a screenshot of where this is set in Views UI :)

Only local images are allowed.

subscribe

Same issue... but I wasn't able to remove it by deleting calendar_date_link_[content_type] in my variables table.

subscribe

I have this same issue in 6.x-2.2.

To add to the above comments;
I've found that the date changer form in the Calendar page display also posts to the default path (calendar-date) and not the overridden one.

I checked the export text of my view and the default path: calendar-date doesn't appear in the content. But as noted above it does appear in the database.

I couldn't gather from the above comments if deleting the custom date link row (calendar_date_link_[content_type]) deletes the link from the pages or forces it to update to the correct path. So instead of deleting the offending row (my content type is called: camp_content); calendar_date_link_camp_content = s:13:"calendar-date", I changed the value:
variable table > calendar_date_link_camp_content to s:13:"camp-calendar"; and cleared both my caches and it works.

I'm not a fan of hard coding values into the database so I'll be interested to see how the patch works out.

Thanks for the screenshot. Just clicking on"Add new date link" and resaving the page view seemed to fix it for me--possibly the URL is updated then?

In my case, I'd changed the path to my calendar after enabling the 'Add new date' feature, and the link set up in calendar_date_link_[content_type] didn't update.

I was also able to fix that stale view path by setting "Add new date link" to none, saving and then re-enabling it for my content type.

Ran into the same issue. Actually deleted the view the link was pointing to, but the variable was still in there, creating a broken link. Had to manually delete the variable from the database. Considering the age of this issue and how ugly the behaviour is, someone should really fix this.

Subscribe, the same problem. The link in my case leads to an old view which does not exist any more. Really confusing behavior.
#15: +1

Subscribe,

Even after deleting the variable from the database, which caused the link on the node page to go away, when editing the view, it still says, "broken field."

Subscribing.

Subscribing as well. However, the workaround in post #1 worked just fine here.

Priority:Normal» Major

> Even after deleting the variable from the database, which caused the link on the node page to go away, when editing the view, it still says, "broken field."

That's another bug, for which I filed a patch: #372988: Add new date link: Broken field.

There are in fact two bugs here:

1. If you select 'no link' in the Views calendar display settings, then a variable called 'calendar_date_link_' is created, which is useless. That's just a bit of missing logic in the plugin's options_submit().

2. More seriously, the code is setting a variable which it's *impossible* to remove. If I once accidentally clicked that 'Add new date link' setting and chose something at random, and then deleted the view, the variable persists, and so does the faulty link on nodes. This is pretty major.

... and to people wanting to fix their links:

- install devel module
- using the variable editor, delete ALL variables that begin with 'calendar_date_link_'.
- don't visit the 'Add new date link' setting form again!

Subscribe!

Thank you, nadavoid! Removing the variable worked for me!

In my case the link was displayed even for people, who did not have the permission to view the calendar, so they received 'page not found' after clicking it

Subscribing. I'm having the same problem with a Calendar link in my event nodes that points to the wrong View.

Subscribe...

Status:Active» Fixed

Edit your view. Click on 'Calendar page'. Looks at 'Calendar settings'. See the option for the 'Add new date link'. Change it to 'none'. That will give you no connection between a content type and a calendar -- no link to create a new event, no link back to the calendar.

That's not a good solution when you have a site like ours, where our registered users can post events on the events calendar. They need an "Add" link on the calendar so they can add events.

Karen may have not given you the final step here - as described in #13 and #14 above, if you set the 'add new date link' option to none, save the view, and then check the 'add new date link' option again and resave, the link should be updated to point to the correct view.

I'd like it if the view settings were smarter and took care of that themselves, but this workaround got me back on the road, so I just went with it.

Status:Fixed» Active

I could fix this issue only with "Devel" module: deleting the calendar variable by hand, so moving this issue to active status.
I try to update the calendar-page setting, but I couldn't remove the "node/%/calendar" link.

NikLP: that's a 'ok' start but doesn't really remove everything. I still makes the <ul> and <li> render in the page.

#21 works for me!

This is the complete behavior (Calendar 6.x-2.4 and Date 6.x-2.7):
1. when you set a content type at the "Add new date link" the variable "calendar_date_link_CONTENTTYPE" created (immediately after push "Update" button and with a correct working link - for me).
2. and when you try to set the "No link" value, then the "calendar_date_link_CONTENTTYPE" variable wont remove, but a new variable created "calendar_date_link_" (with the same value).

Status:Active» Closed (won't fix)

While I 'm not sure this can be classified as fixed (at minimum - it's definitly not user-friendly) the work-around that KarenS mentions in #27 does work and you don't need to tweak variables with the devel module. Karen doesn't spell out the complete steps and they don't seem to be assembled in one post in this thread, so here they are:
1. Edit your calendar view, select the calendar page display
2. Look for the calendar settings box in the view conf area and click on "Add new date link"
3. Set "Add new date link" to "no link"
4. Save your view
5. Edit your view, select the calendar page display
6. Look for the calendar settings box in the view conf area and click on "Add new date link"
7. Set "Add new date link" to whatever is the appropriate content type for this calendar view.
8. Save your view

This has worked for me. If it doesn't work for everyone else, then someone should reopen this.

So, if there is a bug here, I would describe it as - changing "Add new date link" in calendar view does not successfully update and "add new date links" throughout the site.

If Karen doesn't feel the above behavior is a bug and doesn't plan to fix it, then someone should create a feature request about this for a future version of Calendar.

Version:6.x-2.x-dev» 6.x-2.4
Priority:Major» Normal
Status:Closed (won't fix)» Active

Although #33 addresses how to change, the issue remains on how to remove it altogether. Setting it to "none" does not actually remove the Calendar Link under the node body. Changing to Active.

(Karen, thanks!)

Subscribing...

Subscribing...

subscribing

subscribing...

Version:6.x-2.4» 7.x-3.x-dev

I couldn't see how to use the method described in #33 because Views for Drupal 7 has a completely different interface, and I couldn't find an "Add new date link" to clear out. I also tried deleting the 'calendar_date_link_' from the variable table and it did go away temporarily, but came back again. Any clues as to how to get around this for Drupal 7?

Workaround if you're using Features+Strongarm: set the default value of 'calendar_date_link_[nodetype]' to blank - the link will not be rendered. Tested for D6, but probably works for D7 as well.

From my feature code:

$strongarm->name = 'calendar_date_link_event';
$strongarm->value = '';

This workaround is portable to other Drupal installations if you export it to your 'Event' feature.

Status:Active» Fixed

I reworked this code to add some helper functions. When you set the link to none it will also clear out any previous links to this view. And you can use the helper functions to clear all links. calendar_clear_link_path($path) clears all links to a path, or all links to all paths if $path is empty. Similarly, calendar_clear_link_bundle($bundle) clears all links to a bundle or all links to all bundles if $bundle is empty.

http://drupalcode.org/project/calendar.git/commit/4e75cb2

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Hi
I've been reading this whole string (a couple of times :-) but it appears that the fix is only for v6 and not 7?? Maybe I've read it to many times but I'm confused... Is there a solution for 7?

Thanks!

I'm confused, how to fix this issue?
thanks in advance.

I see the helper functions, but I don't know how to try.

edit: sorry I'm using D7

Version:7.x-3.x-dev» 6.x-2.2

I'm still experiencing the same problem even with the interface fix mentioned above. I'm running Drupal 6 and I have a half dozen calendars running from one content type, an Event content type I created. We're using Organic Groups and taxonomies to distinguish the different calendar events and have them appear on the appropriate calendar. Everything works fine except the Calendar link that appears on all the Event nodes. Whenever I go into the View for a group's calendar and change the, "Add new date link" setting it sets all the Calendar links on all the Events to lead back to the one I just saved. As I go through and try to save the link to none or to the Event content type on each View, it just spits out the last view URL for the Calendar link on all Event nodes. I'd rather not hack into the module to make it go away. And my users want the Calendar link there but it needs it to go to their calendar. The only solution I can see at this point is to create a unique content type for each calendar and recreate all the Views... Not looking forward to that.

subscribing

Status:Closed (fixed)» Needs work

I followed the lead of #7 and created a simple module which only includes this:

<?php
function calendar_link_removal_node_view_alter(&$build) {
  foreach (
$build['links'] as $module => $link) {
    if (
strstr($module, 'calendar')) {
     
// remove the broken link back to the calendar - see http :// drupal.org/node/462748#comment-2099126
      // don't know if this breaks any other calendar links?!
     
unset($build['links'][$module]);
    }
  }
}
?>

This worked in removing the link from all pages that it had been placed on. I've not done more tests but this is at least a simple d7 solution.

Or you can change the link to link to something a bit more useful. I've changed mine to link to the calendar month view of the month of the event I'm looking at.

function yourmodule_link_alter(&$links, $node) {
  foreach ($links as $module => $link) {
    if ($module == 'calendar_link') {
      $links[$module]['href']='events/'.substr($node->field_event_date[0]['value'],0,7);
      $links[$module]['attributes']['title']='View calendar for '.date("F Y",strtotime(substr($node->field_event_date[0]['value'],0,7)));
    }
  }
  return;
}

Note: my event node's date field is field_event_date and I'm linking to "events/YYYY-MM". You might want to tweak for your use case.

Thanks for the D7 solution from #47

I think if this module is going to add links to the bottom of any event nodes, it needs to be a configurable option.

The solution mentioned in #33 above works for D7. I don't want the links at the bottom of my nodes, so I did the following:

1. Went to the calender view. All of the pages had an 'Add new date link' value of 'No Link' (yet there was still a link).
2. I changed one of the page views values to show a link on my event type and saved.
3. I then changed the value back to 'No Link' - now the link is gone.

So, there is a work around that doesn't involve a custom module...

I got this problem with calendar for D7. After some tweaks, it seems the problem is related to session/cookies... Set "Add new date link" to "no link" and then delete the session cookie (something like SESS8f310b6c596e998ec1b20ac75217fc30). The link is gone :)

The code involved (D7 version):

calendar.module
/**
* Implements hook_menu_local_tasks_alter().
*
* Takes the calendar links created in calendar_preprocess_date_views_pager()
* and reconfigures them as action items. The links can be altered
* before they are displayed using hook_calendar_links_alter().
*/
function calendar_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  if (!empty($_SESSION['calendar_links']) && array_key_exists($root_path, $_SESSION['calendar_links'])) {
    $calendar_data = $_SESSION['calendar_links'][$root_path];
    if (!empty($calendar_data['actions'])) {
      foreach ($calendar_data['actions'] as $action) {
        $item = menu_get_item($action['path']);
        $item['title'] = $action['title'];
        // The add new content page would redirect to the new event
        // if we did not override that here. This way they will
        // redirect back to the calendar.
        $item['localized_options'] += array('query' => array());
        $item['localized_options']['query'] += drupal_get_destination();
        if (array_key_exists('access', $item) && $item['access']) {
          $data['actions']['output'][] = array(
            '#theme' => 'menu_local_action',
            '#link' => $item,
          );
        }
      }
    }
  }
  return;
}

Hope it helps.
Jerome

#50 worked. Thanks

I also struggled to find the 'Add new date link' setting. Here is location in D7.

On view settings page:
-Month view
-Format section
-'Show: Calendar Entities / Settings'
-Select 'Settings'
-Scroll down to 'Add new date link' and make changes.

I can confirm that #50 worked for me. None of my year/month/day/week display had a link, but it was still showing on the event pages.

I created a new display of type page, with the format set to 'grid' and the 'show:' field set to 'calendar entities'. I set 'add new date link' to 'Event' (see #53), saved the view (after making a dummy path for it), changed 'add new date link' back to 'no link', and saved the view again. Having done this, no link was displayed on the Event pages.