List of Pending Comments?
#1
Posted 05 June 2012 - 04:11 PM
I was wondering whether it is possible to display a list of all pending comments somewhere? I have hundreds of pages where visitors can comment and checking them all in the admin page is not really an option.
... of course there's the email notification, but would be great if that's not the only way ...
Thanks,
Lars
#2
Posted 05 June 2012 - 05:51 PM
foreach ($pages->find("comments.status=0") as $c){ // status 0 means pending
echo "<li><a target='_blank' href='{$config->urls->admin}page/edit/?id={$c->id}'>{$c->title}</a></li>";
}If I have time tomorrow, I can try to make a process module with this, so you can have the list on an admin page.
#3
Posted 05 June 2012 - 06:08 PM
It would be really great to have it on the admin page - if you have time, it would be amazing.
Or maybe you could give me brief outline on how to write this module and I can give it a try myself? The hello world module only shows how to add hooks ... but how to add an admin page?
Thanks again,
Lars
#4
Posted 06 June 2012 - 09:23 AM
Just install it and create a page as child of "admin" with the "admin" template, and assign the process "ProcessCommentsList" to it.
Edit: changed some details on the module
Edit2: added some options to the module settings
Edit3: updated the module with some changes suggested by Ryan
Edit4: minor change -- replaced the word "Sentence" by "Message" on the options
Edit5: No need for a title when outputting the link to the page. If it is not there, the name is used instead
Attached Files
Edited by diogo, 06 June 2012 - 11:58 AM.
#5
Posted 06 June 2012 - 09:42 AM
I adjusted it slightly by finding pages with the comments field name as the one I am using instead of 'comments':
find("article_comments.status=0")
Unfortunately, it now only shows an empty page as if it is not finding anything - there are pending comments though.
When I do something like find("template=xyz") it works fine ... ?
Thanks,
Lars
Edited by Lars282, 06 June 2012 - 09:54 AM.
#7
Posted 06 June 2012 - 11:02 AM
It is the same problem as before: It displays the message for when there are pending comments, but then does not list any pages ...
Again, if I replace find("$field.status=0") with something like find("template=xyz"), where xyz is a template I am using, then it displays some pages ...
Edited by Lars282, 06 June 2012 - 11:10 AM.
#8
Posted 06 June 2012 - 11:10 AM
I would try making it
$p = wire('pages')->find("$field.status=0, include=all");
@somartist | modules created | support me, flattr my work flattr.com
#10
Posted 06 June 2012 - 11:26 AM
#11
Posted 06 June 2012 - 11:27 AM
I just installed and works well diogo. Nice work here. Could be improved to maybe even approve them directly on the admin page.
@somartist | modules created | support me, flattr my work flattr.com
#12
Posted 06 June 2012 - 11:32 AM
#15
Posted 06 June 2012 - 11:42 AM
Hm, this is how it appears in the admin/fields page:
Is that the correct one to use?
.... and show us a screen shot of the module' config screen...
@somartist | modules created | support me, flattr my work flattr.com
#16
Posted 06 June 2012 - 11:47 AM
Thanks so much diogo! I might try to extend this module to include more functionality, and upload here once I do.
Thanks again for your help!
#17
Posted 06 June 2012 - 11:55 AM
the pages in question have an empty title field, due to their nature ... so the <a></a> were created properly but just invisible
Updated the module to prevent this to happen. Now it checks for the title, and if it isn't there, it outputs the name
$out .= $c->title ? $c->title : $c->name;
#19
Posted 06 June 2012 - 01:20 PM
/**
* Status for Comment identified as spam
*
*/
const statusSpam = -2;
/**
* Status for Comment pending review
*
*/
const statusPending = 0;
/**
* Status for Comment that's been approved
*
*/
const statusApproved = 1;
@somartist | modules created | support me, flattr my work flattr.com
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users















