Good evening,

I am developing an accessible theme for Drupal 7, for an accessible front end for now.
The main problem I am facing is how to remove the line when consulting a general discussion.
It is the value of the variable $regex in comment.test (module: comment).
The line is
$regex .= 'id . '"(.*?)'; //
from the function
function commentExists($comment, $reply = FALSE)

As I don't know how to use in the navigation, how could I remove it from the template or from the template.php file?

Thanks in advance

Francesco

Comments

betarobot’s picture

Comment.test is not rendered (it's a simple test file), so you should not worry about it. As well as you should not modify any (core) modules directly for themeing purposes.

Most probably what you are talking about is <?php print $permalink; ?> in comment.tpl.php. You can just remove it.

At the other hand it is there exactly for accessibility reasons so sou could save a link / access exactly *this* comment. I.e.: http://drupal.org/node/823918#comment-3073530

StevenMouret’s picture

I have the same problem, $permalink contains a link to the comment, not anchor it.
How to rewrite the link <a id="comment-X"></a> and put the id on the container of the comment.

Not

<a id="comment-X"></a>
<div>
...
</div>

But

<div id="comment-X">
...
</div>

Thx

betarobot’s picture

Which theme are you using? I don't see this anchor at all in a few I use...

StevenMouret’s picture

Basic theme but le link <a id="comment-X"></a> is not in the template. It's the Drupal Core that adds this line. In the comment module in the file comment.module to the line 951

    // Add anchor for each comment.
    $prefix .= "<a id=\"comment-$comment->cid\"></a>\n";
    $build['#prefix'] = $prefix;
betarobot’s picture

Oh, right :)

Actually you should not remove this anchor. It is used by many modules to get to exactly *this* comment from blocks or other pages.

francesco_sardegna’s picture

Thanks to all for your help!
I decided to keep the anchor (said the fox to the grapes :-) ), I shall try to wrap it in an appropriate tag (<a> can't stand unwrapped according to W3c) and to create links to in order to make it useful.

I am going ahead with my accessible theme.
I already released one for Wordpress, one for Joomla and one for PhpBB (the only one on the Net I think).
I will keep you posted about the release.
Thanks again.

mgifford’s picture

See the accessible theming stuff here - http://drupal.org/node/464472

Some discussion of themes here - http://groups.drupal.org/node/82329

Lots of models to look at.

Jeff Burnz’s picture

Wrapping a link in a div does not make it more accessible. The link is the focusable element here, the div does nothing but add some markup, so is pointless.

francesco_sardegna’s picture

I agree, the tag div never has semantic meaning.
The W3c validator suggests that a link shouldn't stay unmarked, but even a p tag doesn't add comfort, as that link is an anchor :-) .
I understood the importance of that anchor so it is better to keep it.
Thanks

no2e’s picture

How can I change this markup?

<a id="comment-1"></a> is not in comment.tpl.php and not in comment-wrapper.tpl.php.

When I click on this empty a element (made visible with a CSS pseudo element) with Devel/Theme developer, it says 'comment-wrapper.tpl.php' is responsible.

dkiiashko’s picture

It`s very simple. You can use hook_comment_view_alter

<?php
function MYMODULE_comment_view_alter(&$build){
   //If you want, add some validation
    unset($build['#prefix']); 
}
?>
Anybody’s picture

Alternative:

function THEME_comment_view_alter(&$build) {
  // Remove the <a id="xxx"></a> links from the comment which are solved
  // a bit dirty currently, just like this function... https://www.drupal.org/node/1306572
  $build['#prefix'] = preg_replace("/<\\/?a(\\s+.*

|>)/", "", $build['#prefix']);
}
?>

http://www.DROWL.de || Professionelle Drupal Lösungen aus Ostwestfalen-Lippe (OWL)
http://www.webks.de || webks: websolutions kept simple - Webbasierte Lösungen die einfach überzeugen!
http://www.drupal-theming.com || Individuelle Responsive Themes

mrupsidown’s picture

What about correcting the formatting of your answer when it's obviously messed up?

thomas.frobieter’s picture

Hey guys,

i don´t see any reason for the current markup (maybe IE fallback purposes or something?).
Why the id´s are not attached directly to the comment wrappers?

However, you can simply remove it as jey7 pointed out.

Now simply override the comment.tpl.php and add:

id="comment-<?php print $comment->cid; ?>"

to your comment wrapper. Anchor links (eg. permalink) will still work.

UPDATE:
Comment indention will no longer work with this solution.

with kind regards
Thomas

Anybody’s picture

Please please help to solve this more cleanly. The current solution is really dirty.

http://www.DROWL.de || Professionelle Drupal Lösungen aus Ostwestfalen-Lippe (OWL)
http://www.webks.de || webks: websolutions kept simple - Webbasierte Lösungen die einfach überzeugen!
http://www.drupal-theming.com || Individuelle Responsive Themes

mrupsidown’s picture

I also needed to get rid of these anchor tags and have the comment IDs on the wrapper elements.

I ended up doing it this way:

If you use comments threading, the #prefix might also contain the indentation wrapper, that is either <div class="indented"><a id="comment-123"></a> (when it's the first reply) or the closing tag of that same div </div><a id="comment-123"></a> so you can't just unset the prefix.

function THEME_comment_view_alter(&$build) {

  $prefix = preg_replace("/<a id=\"comment-.*\"><\/a>/", "", $build['#prefix']);
  $build['#prefix'] = $prefix;
}

And I added the ID back on the comment wrapper in the comment.tpl.php.

<div id="comment-<?php print $comment->cid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

Might not be optimal but seems to work fine...