Help - Search - Members - Calendar
Full Version: Adding anchors to comments
Movable Type Community Forum > Additional Resources > Tips and Tricks
sttati
I'm trying to add an anchor to comment entries so when clicking on a link, it would go straight to that comment entry, though i've yet to figure out the second part as well.

I read the manual about it, but I have no idea where to put MTCommentEntryID mellow.gif

I'm assuming it has something to do with the code that show's the comments, right?

CODE
<MTComments>
<div class="comments-body">
<$MTCommentBody apply_macros="1"$>
<span class="comments-post">Posted by: <$MTCommentAuthorLink spam_protect="1" show_email="0"$> at <$MTCommentDate$></span>
</div>
</MTComments>


Is what I'm using now. Do I add the MTCommentEntryID somewhere there, or somewhere else, or add it to something? (I'm using individual archives by the way, not the popup)

Also, I wish to have the links from the most recent comments (which I already have set up), to go to that comment entry, not just the individual archive.

CODE
<MTComments lastn="5" sort_order="descend">
<MTCommentEntry> <b><$MTCommentAuthorLink show_email="0"$></b>:  "<MTCommentBody trim_to="50" remove_html="1" convert_breaks="0"> ..." [<a href="<MTEntryLink>" title="view the entry">go</a>]
<br /></MTCommentEntry></MTComments>


That is the code I use, where would I add the anchor thingymabob?

Thanks smile.gif
medic119
Try this:

CODE
<MTComments>
<a name="<MTCommentEntryID>"></a>
<div class="comments-body">
<$MTCommentBody apply_macros="1"$>
<span class="comments-post">Posted by: <$MTCommentAuthorLink spam_protect="1" show_email="0"$> at <$MTCommentDate$></span>
</div>
</MTComments>


To create an achor you use <a name="Anchor">
sttati
Okay, so I added that in. Read through the manual a little more, and added in the little thingos so that links will go straight to the comments. On the main page it's

CODE
<MTComments lastn="5" sort_order="descend">
<MTCommentEntry> <b><$MTCommentAuthorLink show_email="0"$></b>:  "<MTCommentBody trim_to="50" remove_html="1" convert_breaks="0"> ..." [<a href="<MTEntryLink>#<$MTCommentID$>" title="view the entry">go</a>]
<br /></MTCommentEntry></MTComments>


But it still doesn't work.

I checked the source on the indiviual archive for the comments, is it meant to have
CODE
<a name="comments ">
only, or is there more?

My site can be reached at http://sttati.com
girlie
Did you update the code in your Individual Archive the way medic showed you:

CODE
<MTComments>
<a name="<MTCommentEntryID>"></a>
<div class="comments-body">


then rebuild all your individual archives?
sttati
Yep, I added in exactly what he put there.
hochan
put this code in individual archive template.

CODE
<MTComments>
<a name="<MTCommentID>"></a>
<div class="comments-body">
girlie
Ahh, yeah, hoochan's right - medic gave you MTCommentEntryID - which isn't what you want. The anchors need to use the comment's ID, not the entry's ID.

Use hoochan's code and rebuild your individual archives again.
medic119
oops.. ohmy.gif
sttati
Alright, here's what I've got

Individual archives
CODE
<MTComments>
<a name="<MTCommentEntryID>"></a>
<div class="comments-body">
<$MTCommentBody apply_macros="1"$>
<span class="comments-post">Posted by: <$MTCommentAuthorLink spam_protect="1" show_email="0"$> at <$MTCommentDate$></span>
</div>
</MTComments>


And for on the main index, where the recent comments thingo goes
CODE
<MTComments lastn="5" sort_order="descend">
<MTCommentEntry> <b><$MTCommentAuthorLink show_email="0"$></b>:  "<MTCommentBody trim_to="50" remove_html="1" convert_breaks="0"> ..." [<a href="<MTEntryLink>#<MTCommentID>" title="view the entry">go</a>]
<br /></MTCommentEntry></MTComments>


Now I'm sure that the above code is wrong, but have no idea where.

Don't know if this'll help, but the comment link that comes up is like
QUOTE


Sorry that I'm a tad slow on this.
girlie
QUOTE (hochan @ May 24 2003, 07:39 AM)
put this code in individual archive template.

CODE
<MTComments>
<a name="<MTCommentID>"></a>
<div class="comments-body">

You need to change MTCommentEntryID to MTCommentID in your Individual template.
johnkranz
QUOTE (girlie @ May 25 2003, 03:26 PM)
QUOTE (hochan @ May 24 2003, 07:39 AM)
put this code in individual archive template.

CODE
<MTComments>
<a name="<MTCommentID>"></a>
<div class="comments-body">

You need to change MTCommentEntryID to MTCommentID in your Individual template.

I'm going through the same exercise and problem with frustrating results. The html link destination is correct on the index.html page to the individual archive page, but still no luck, the browser simply isn't navigating properly to the comment itself. sad.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.