Download & Extend

Unable to change or remove the Calendar link under node body

Project:Calendar
Version:7.x-3.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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.

Comments

#1

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 request» bug report

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"

#2

Same problem... subscribing.

#3

same problem

#4

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.

#5

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

#6

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.

#7

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]);
    }
  }
}
?>

#8

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.

AttachmentSize
Picture 24.jpg 101.77 KB

#9

subscribe

#10

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

#11

subscribe

#12

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.

#13

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?

#14

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.

#15

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.

#16

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

#17

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."

#18

Subscribing.

#19

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

#20

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.

#21

... 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!

#22

Subscribe!

#23

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

#25

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

#26

Subscribe...

#27

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.

#28

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.

#29

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.

#30

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.

#31

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

#32

#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).

#33

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.

#34

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!)

#35

Subscribing...

#36

Subscribing...

#37

subscribing

#38

subscribing...

#39

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?

#40

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.

#41

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

#42

Status:fixed» closed (fixed)

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

#43

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!

#44

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

nobody click here