ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Link to paginated comments with anchor - how?

July 28, 2011 7:26pm

Subscribe [2]
  • #1 / Jul 28, 2011 7:26pm

    lehrerfreund

    263 posts

    Hi,

    I show the newest 10 comments as link-list with a template like this (shortened):

    {exp:comment:entries orderby="date" limit="8" dynamic="no" channel="xy" }
        {name} to entry 
    <a href="http://{title_permalink=">{title}</a>
    
    
    {/exp:comment:entries}

    I paginate my comments, when an entry has more than 100 comments, they are paginated.
    But when I generate the anchor-links to the comments as shown above, the pagination is ignored - the link is xy/#c-280 instead of xy/P3/c280

    Is there a trick to solve this or is it impossible?

    Thanks in advance!

  • #2 / Jul 29, 2011 2:25pm

    Kevin Smith

    4784 posts

    I’m actually not sure how you’re getting a proper URL at all with your code; it looks like you never close the title_permalink tag. Have you tried the permalink variable instead?

  • #3 / Jul 30, 2011 5:30am

    lehrerfreund

    263 posts

    The code was messed up by the code-tag in here; I am sure this is a bug of the forum, tried several times.  i originally entered the code

    < a h ref=" { title _permalink = " { my _template_group } / 1s " } # c -{ comment_id } ">{title}</a>

    (this time added some blank spaces to get it work)

    With this code I get an URL like http://www.xy.de/in/schule/1s/abzaehlreim-unterricht#c-18843 which works but ignores the pagination.

    With

    <a href="http://{permalink}">{title]</a>

    I get an URL like http://www.xy.de/in/#18843 , which is bad, because it doesn’t work 😊

    In both cases the pagination is ignored.

  • #4 / Aug 02, 2011 8:44pm

    Lisa Wess

    20502 posts

    The code tag is messing that up because you’re nesting identical quotes.

    Try like this:

    <a href="http://{title_permalink=%27{my">{title}</a>

    And you should do the same in your templates - it’s a better practice in general.

    I don’t see any pagination code in your listed code in your first post either.  You can find the options here.

    if that’s still not working, can you post your full template and a link to the page you’re testing this on?

    And when you respond, do please also include your installed EE version.  Thanks!

    Thanks!

  • #5 / Aug 03, 2011 4:42pm

    lehrerfreund

    263 posts

    Hi Lisa,

    ok, this is the reason, thanks for pushing me onto this. Usually I don’t nest identical quotes, it’s a pest.

    Ok:

    Template one - displays the newest comments:

    {exp:comment:entries sort="desc" orderby="date" limit="8" dynamic="no" channel="lehrerfreund" cache="yes" refresh="60" disable="category_fields"}
      <li>
        <ul>
          <li class="komAutor">
        {name}, {comment_date format="%d.%m."} zu
          </li>
          <li class="komTitel">
        <a href="http://{title_permalink=%27{my_template_group}/1s%27}#c-{comment_id}" title="Kommentar zu '{title}'">{title}</a>
          </li>
        </ul>
       </li>
    {/exp:comment:entries}

    The 1s-template (single entry with pagination) has a code like this:

    {exp:channel:entries channel="{my_channel}" limit="1" disable="member_data|trackbacks|pagination" track_views="four" status="open"}
    
                {title}
    {body}
    
    {/exp:channel:entries}
    
    {exp:comment:entries sort="asc" orderby="date" dynamic="yes" cache="yes" refresh="10" limit="100"}
    
                        (<a href="http://{title_permalink={my_template_group}/1s}/#c-{comment_id}">#{absolute_count}</a>)
                        {url_as_author}
    
    {comment}
                      
    {paginate}
    <div class="schalterli">
    <a href="#top">/bilder/deko/top.gif</a>  
    
    {if {total_pages} > 1}
    
    {if previous_page}
    <a href="http://{auto_path}">/bilder/deko/links.gif</a>  
    {/if}
    
     Seite {current_page}/{total_pages}
    
    {if next_page}
    <a href="http://{auto_path}">/bilder/deko/rechts.gif</a>
    {/if}
    
    {/if}
    
    </div>
    {/paginate}
    {/exp:comment:entries}

    When you go to http://www.lehrerfreund.de/ in the right bar you find “Neueste Kommentare” (first template). The problem is that it does always link to the first page and not to P800 - e.g. http://www.lehrerfreund.de/in/schule/1s/wieviel-verdienen-lehrer#c-18860 instead of http://www.lehrerfreund.de/in/schule/1s/wieviel-verdienen-lehrer/P800#c-18860 .

    I hope I managed to formulate understandable 😊

  • #6 / Aug 04, 2011 12:11pm

    Kevin Smith

    4784 posts

    Since new comments bump older comments into the next pages, if EE generates permalinks to comments and includes the P800 in the URL and someone links to that comment, that comment might eventually not be on the comments page that we reach using that URL once enough new comments bump that comment off the page. That’s convoluted, I know, but does it make sense?

    So… if you’re going to use pagination with comments, it looks like the solution is to create a link to that specific comment. In other words, create a page that will display a particular comment based on the comment ID in the URL, and then use that URL structure as your permalink. Does that help?

  • #7 / Aug 04, 2011 12:34pm

    lehrerfreund

    263 posts

    Hi Kevin,

    do you mean that I would have to generate a link to specifics comment manually? That’s not practicable.

    So there is no way to generate automatically links to paginated comments, if I understand this right. No problem - I am just disabling pagination for entries; entries with more comments have to load a bit longer, may the patience with the users.

    Thanks for helping me, Lisa and Kevin!

  • #8 / Aug 05, 2011 3:29pm

    Kevin Smith

    4784 posts

    Right, I’m just saying it’s not something that’s technically possible in EE because the “P20” part of the URL string would change as the comments are bumped onto successive pages. So if you want to provide permalinks to specific comments and paginate your comments at the same time, you’ll need to create a new template that pulls the comment ID out of the segments and displays that particular comment. It’s not elegant, I agree, but it’s the best way to accomplish what you’d like to accomplish here.

    Sounds like you understand the complexity of the situation here; going without pagination allows you to provide permalinks with all the comments displayed on one page. Is it ok with you if I mark this thread as resolved?

  • #9 / Aug 05, 2011 3:40pm

    lehrerfreund

    263 posts

    Yes, Kevin, I understand the complexity.  I am just going to forget about pagination.

    Thanks again for your help. So from my side the topic is solved.

  • #10 / Aug 05, 2011 6:37pm

    Kevin Smith

    4784 posts

    Sounds good, lehrerfreund. Let me know if you need anything else.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases