How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

View: New views
8 Messages — Rating Filter:   Alert me  

How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

by William Canino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I figured the first one by myself, but now I am quite stuck.

1. My theme has no nested comments, but uses <ol> instead of <ul>

How do I number the paged comments (<ol start="?"> to maintain comment
numbering. For example, if I chose 10 comments per page, the comments
at page two will start at 11. How do I get that 11?

2. I want to echo my <div class="navigation"><?php
paginate_comments_links() ?></div> only if there is actual comment
paging.  What condition should I test?  I'm stuck because
paginate_comments_links doesn't seem to support $before and $after.

Have a good evening, everyone.

W

P.S. Is there an automattic discussion list particularly for theme developers?


2009/11/5 William Canino <william.canino@...>:
> After a year of procrastinating, I will begin implementing
> wp_list_comments() on a theme.
>
> Does anyone know any tutorial for making one's own Walker_Comment?
> Sorry if I sound so lazy.
>
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

by Andrew Nacin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> 2. I want to echo my <div class="navigation"><?php
> paginate_comments_links() ?></div> only if there is actual comment paging.
>

You could use the echo=false arg and check the length of the returned
string.
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

by Mike Little :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/5 Andrew Nacin <anacin@...>

> >
> > 2. I want to echo my <div class="navigation"><?php
> > paginate_comments_links() ?></div> only if there is actual comment
> paging.
> >
>
> You could use the echo=false arg and check the length of the returned
> string.
>

>

I don't believe that will work: the default comment_walker *always* echoes.


See this trac ticket for a report and fix
http://core.trac.wordpress.org/ticket/10948


Mike
--
Mike Little
http://zed1.com/
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

by Andrew Nacin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> I don't believe that will work: the default comment_walker *always* echoes.
>

#10948 is for wp_list_comments()... paginate_comments_links() only relies on
the walker to determine the number of pages required (and even then only
when threading is on, otherwise it uses $wp_query).  It accepts echo=false
without any problem.

Andrew
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

by Mike Little :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/11/5 Andrew Nacin <anacin@...>

> >
> > I don't believe that will work: the default comment_walker *always*
> echoes.
> >
>
> #10948 is for wp_list_comments()... paginate_comments_links() only relies
> on
> the walker to determine the number of pages required (and even then only
> when threading is on, otherwise it uses $wp_query).  It accepts echo=false
> without any problem.
>
>
Doh! That's what I get for not reading things properly, thanks for
clarifying that.

Mike
--
Mike Little
http://zed1.com/
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

by William Canino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>> It accepts echo=false without any problem.

Yes it does. However, I may end up using ( get_comment_pages_count() >
1 ) as it is more good-looking.  That leaves me with the other
quandary:

> 1. My theme has no nested comments, but uses <ol> instead of <ul>
>
> How do I number the paged comments (<ol start="?"> to maintain comment
> numbering. For example, if I chose 10 comments per page, the comments
> at page two will start at 11. How do I get that 11?

Do you think

<ol start="<?php echo ( get_query_var('cpage') - 1 ) *
get_query_var('comments_per_page') + 1 ?>">

is okay and wouldn't cause problems or fail later?

I am just being careful about these undocumented functions.


2009/11/5 Mike Little <mike@...>:

> 2009/11/5 Andrew Nacin <anacin@...>
>
>> >
>> > I don't believe that will work: the default comment_walker *always*
>> echoes.
>> >
>>
>> #10948 is for wp_list_comments()... paginate_comments_links() only relies
>> on
>> the walker to determine the number of pages required (and even then only
>> when threading is on, otherwise it uses $wp_query).  It accepts echo=false
>> without any problem.
>>
>>
> Doh! That's what I get for not reading things properly, thanks for
> clarifying that.
>
> Mike
> --
> Mike Little
> http://zed1.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers@...
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

by William Canino :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Buggers! get_comment_pages_count() returns more than 1 even if the
get_option('page_comments') setting is off. Therefore I gotta check
both conditions.

Reference: See http://phpxref.ftwr.co.uk/wordpress/wp-includes/comment.php.source.html#l588
.

A tip to anyone who is off to number the paged comments, too: <ol
start> only works with the "older comments at the top" setting,
because this tag doesn't do reverse numbering.


2009/11/5 William Canino <william.canino@...>:

>>> It accepts echo=false without any problem.
>
> Yes it does. However, I may end up using ( get_comment_pages_count() >
> 1 ) as it is more good-looking.  That leaves me with the other
> quandary:
>
>> 1. My theme has no nested comments, but uses <ol> instead of <ul>
>>
>> How do I number the paged comments (<ol start="?"> to maintain comment
>> numbering. For example, if I chose 10 comments per page, the comments
>> at page two will start at 11. How do I get that 11?
>
> Do you think
>
> <ol start="<?php echo ( get_query_var('cpage') - 1 ) *
> get_query_var('comments_per_page') + 1 ?>">
>
> is okay and wouldn't cause problems or fail later?
>
> I am just being careful about these undocumented functions.
>
>
> 2009/11/5 Mike Little <mike@...>:
>> 2009/11/5 Andrew Nacin <anacin@...>
>>
>>> >
>>> > I don't believe that will work: the default comment_walker *always*
>>> echoes.
>>> >
>>>
>>> #10948 is for wp_list_comments()... paginate_comments_links() only relies
>>> on
>>> the walker to determine the number of pages required (and even then only
>>> when threading is on, otherwise it uses $wp_query).  It accepts echo=false
>>> without any problem.
>>>
>>>
>> Doh! That's what I get for not reading things properly, thanks for
>> clarifying that.
>>
>> Mike
>> --
>> Mike Little
>> http://zed1.com/
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers@...
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: How to number the paged comments in theme Was: Tutorial for custom Walker_Comment ?

by Andrew Nacin :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>
> A tip to anyone who is off to number the paged comments, too: <ol

start> only works with the "older comments at the top" setting,

because this tag doesn't do reverse numbering.


You can manually specify the value of a list item in HTML. Also, the HTML5
spec includes a reversed attribute for ordered lists, though I don't think
any browser implements it yet.
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers