Skip to:
Content

Opened 15 months ago

Closed 15 months ago

Last modified 15 months ago

#4770 closed enhancement (fixed)

Linking in the forum loop

Reported by: chouf1 Owned by:
Milestone: 1.7 Priority: normal
Severity: normal Version: 1.2
Component: Forums Keywords: commit
Cc:

Description

While building the buddy bbpress support topic plugin, we encontered a small detail about redondancy while trying to apply css styling into the forum loop.

Actually the forum-loop contains this

<a class="topic-title" href="<?php bp_the_topic_permalink(); ?>" title="<?php bp_the_topic_title(); ?> - <?php _e( 'Permalink', 'buddypress' ); ?>">

To add some text before the title, we use in our plugin

return __('[Resolved] ', 'buddy-bbpress-support-topic') . $topic_title;

And to add some style to the additionnal text we use:

return '<span class="green">'. __('[Resolved] ', 'buddy-bbpress-support-topic').'</span> '. $topic_title;

But the final result is wrong and weird !

<a class="topic-title" href="http://example.com/groups/test/forum/topic/plugin-test" title="<span class=" green"="">[Resolved]  Plugin test - Permalink"&gt;
						<span class="green">[Resolved] </span> Plugin test </a>


And on the frontend we see: [Resolved] Plugin test - Permalink"> [Resolved] Plugin test !!!

To get it correctly, we had to retrieve the bp_the_topic_title from the forum-loop :

<a class="topic-title" href="http://example.com/groups/test/forum/topic/plugin-test" title="Permalink to this post">
						<span class="green">[Resolved] </span> Plugin test </a>

The title attribute is optional. But when used, it has to give additonnal information. In the present case, for the anchor. The href contains the post title in the URI, and the additionnal information to this formed link is "permalink". So it's not necessary to repeat the post title in the title attribute.
http://www.w3.org/TR/html401/struct/links.html#h-12.1.3

I suggest to modify the actual loop from this

<a class="topic-title" href="<?php bp_the_topic_permalink(); ?>" title="<?php bp_the_topic_title(); ?> - <?php _e( 'Permalink', 'buddypress' ); ?>">

to this

<a class="topic-title" href="<?php bp_the_topic_permalink(); ?>" title="<?php _e( 'Permalink to this post', 'buddypress' ); ?>">


Change History (5)

comment:1 r-a-y15 months ago

  • Component changed from Forums to Theme
  • Keywords dev-feedback added
  • Version set to 1.2
<a class="topic-title" href="<?php bp_the_topic_permalink(); ?>" title="<?php _e( 'Permalink to this post', 'buddypress' ); ?>">

I'm okay with this change in /forums/forums-loop.php. Any objections from the other devs?

comment:2 boonebgorges15 months ago

Looks good to me.

comment:3 DJPaul15 months ago

  • Component changed from Theme to Forums
  • Keywords commit added; dev-feedback removed
  • Milestone changed from Awaiting Review to 1.7

comment:4 r-a-y15 months ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [6725]) Change 'title' attribute for topic links in group forum loop template.

In the topic title link, bp_the_topic_title() is used twice: once
in the 'title' attribute and again for the anchor text.

For plugin devs wanting to manipulate the HTML markup for the topic
title, this would cause unintended output in the 'title' attribute.

Therefore, this commit removes bp_the_topic_title() from the 'title'
attribute for topic links.

Fixes #4770. Props chouf1.

comment:5 r-a-y15 months ago

Forgot to write in the commit message that I changed the title string to use the already-existing string - 'Permanent link to this post'.

Note: See TracTickets for help on using tickets.