This is the strangest bug that took me forever to figure out the cause of. When webreader is present, any page listing with embedded nodes replaces the title of the page with the title of the node. So for instance, if I have a view listing a nodes, the title of the view page is replaced with the title of the last node.

I suspect it might be this bit of code that is the problem but I have no idea how to go about fixing it. This is happening on pages where webreader isn't enabled.

// Get real node title and insert webReader tags for output of node title
  $nodetitle = $node->title;
  drupal_set_title('<!-- RSPEAK_START -->'. $nodetitle .'<!-- RSPEAK_STOP -->');

Comments

Dejarl’s picture

Priority: Critical » Normal
Status: Active » Fixed

Hi,

It doesn't happen for me, but since it only happens when webReader is disabled I think this is how you can solve the problem:

Cut this code:

  // Get real node title and insert proreader tags for output of node title
  $nodetitle = $node->title;
  drupal_set_title('<!-- RSPEAK_START -->'. $nodetitle .'<!-- RSPEAK_STOP -->');

Paste it just below the "IF" that check if the plugin is activated or not, it should look like this:


  // Modify only, if
  //  alter operation is running
  //  user have permission 'display proreader'
  //  node language is included in supported proreader languages
  //  and proreader account supports current node language
  if ($op == 'alter' && user_access('display proreader') && array_key_exists($language->language, $proreader_languages) && ($lang == 'all' || $lang == $language->language)) {  

  // Get real node title and insert proreader tags for output of node title
  $nodetitle = $node->title;
  drupal_set_title('<!-- RSPEAK_START -->'. $nodetitle .'<!-- RSPEAK_STOP -->');

I hope that this will solve the problem since the plugin will only work with the title if webReader is displayed.

techczech’s picture

Thanks for the quick response. This only solved the problem partially. First, this was happening when Webreader was enabled and fixed itself when I disabled it. Your solution fixed the problem with views listings when only individual fields are presesnt but not when the whole node object is loaded.

The way to replicate is create a view that displays the whole node and is set to one node per page. (See http://www.dyslexiatraining.com/courses/listings/hornsby where the title of the view is taken over by the view).

It's not a problem with this particular view but is more of an issue when I use the nodereference field to display the teaser rather than just the node.

I think the problem is passing the $title variable to the drupal_set_title() function since when the embedded node is present, the available title variable comes from the embedded node. I think the solution might be somewhere in drupal_get_title() function but I'm not sure exactly where.

BTW: This also had an interesting consequence in what is read. Whereas before it just read the node title and body (desired behavior), now it starts at the top of the page.

techczech’s picture

Problem solved! Just as I pressed save on the last posting, the solution appeared to me as if by magic. The problem was exactly as I thought and the fix is simply getting the node variable out of the drupal_get_title() function. So the fix is simply changin the line from:

$nodetitle = $node->title;

to the following:

$nodetitle = drupal_get_title();

It even works when I move the original line back where it was. But then it only seems to read the title (which is something that was sporadically happening before but fixed itself after a while. So I'll see how things go.

Status: Fixed » Closed (fixed)

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

mediamike’s picture

I installed webreader in the normal way. After that, the titles being shown on all my pages were incorrect. So I just disabled the module and it started working again. Not worth it for 4 hours a month of automatic reading.