Creates incorrect links for sites that are in subdirectories

korvus - November 6, 2008 - 16:03
Project:Ignore User
Version:6.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

Instead of using an absolute path to /ignore_user/list, I believe the correct approach is to use base_path().'ignore_user/list'. On my site (currently in a "/drupal" subdirectory off the domain), I was getting a 404 error trying to view the ignore list from some links (as "/ignore_user/list" should be "/drupal/ignore_user/list").

If I am correct, the following changes should be put in place:

Line 236 should read:

<?php
$output
= t('<div class="ignore-user-container">!username is on your <a href="!ignore_list">ignore list</a>. Clic\
k <a href="!node" class="ignore-user-content-link">here</a> to view this post.'
, array('!username' => theme('username', $
authors[$node->uid]), '!ignore_list' => base_path().'ignore_user/list', '!node' => base_path().'node/'. $node->nid));
?>

Line 281 should read:

<?php
$output
= t('<div class="ignore-user-container">!username is on your <a href="!ignore_list">ignore list</a>. Clic\
k <a href="!comment" class="ignore-user-content-link">here</a> to view this post.'
, array('!username' => theme('username'
, $authors[$comment->uid]), '!ignore_list' => base_path().'ignore_user/list', '!comment' => base_path().'node/'. $comment
->nid .'#comment-'. $comment->cid));
?>

I'm not 100% sure the node path changes are necessary, as my site seemed to ignore those paths anyway, but the path was wrong with the old code.

#1

korvus - November 6, 2008 - 16:26

It's also possible that the l() function should be used instead, such as the ignore list link here:

Line 236:

<?php
$output
= t('<div class="ignore-user-container">!username is on your !ignore_list_link. Clic\
k <a href="!node" class="ignore-user-content-link">here</a> to view this post.'
, array('!username' => theme('username', $
authors[$node->uid]), '!ignore_list_link' => l('ignore list','ignore_user/list'), '!node' => base_path().'node/'. $node->nid));
?>

#2

jaydub - November 16, 2008 - 15:12

Ok I see where this could be a problem. Adding links in t() calls is tricky and the Drupal docs for module developers don't really mention this strongly enough. I'll commit to CVS now. Please try the next dev snapshot and if it's working for you I'll roll a release.

#3

korvus - November 17, 2008 - 23:59

The dev version appears to work just fine for me. Thanks!

#4

jaydub - November 27, 2008 - 15:47
Status:active» fixed

#5

System Message - December 11, 2008 - 15:52
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.