Show Latest Comments
jschmittat
Joined: 2005-08-28
Posts: 25 |
Posted: Thu, 2005-11-10 00:58 |
Hi, I tried to extend the comment module so that it can show all latest comments on one page. I am quite of new to the gallery coding stuff but in the end it worked. Your can see the result here: http://www.schmittat.com/gallery2/main.php?g2_view=comment.ShowAllComments Only the comments and photos are shown, the user has the permission to see. This is just a first version, still missing: - Option, how many comments are shown [right now: 5] Looking forward to your feedback! |
|
Posts: 32509
nice
could you also post a diff to the current cvs version?
and better base your changed on the current cvs version of G2 / the current comments module...
Posts: 25
Good idea to use the latest version
I updated my files and also added the possibility to set the number of shown comments in the admin menue.
Diff of module.inc
Diff of GalleryCommentHelper.class
Posts: 25
BTW, if you want to test the feature, just upload the files in zip file to your gallery and upgrade the comments module in the Site Admin area.
Posts: 25
Ok, i worked a bit more on this feature:
- Now, the ShowAllComments page shows only the comments that are children and grandchildren of the current item. That means, if you click on the "Newest Comments" link on the main page, you will see all comments you have the permission to. If you open this view from within an album you just see the comments of that album.
- There is now an option to turn this feature on and off
- I included the captcha feature for anonymous users (http://gallery.menalto.com/node/38933#comment-146386) in a slightly modified version into my comments module. This includes the option to decide in the Admin area whether to use this captcha feature or not.
Ok, here are the diffs:
The files
CommentSiteAdmin.inc
ShowAllComments.inc
AllComments.tpl
CommentSiteAdmin.tpl
and
ShowAllComments.tpl are new
Posts: 25
I am also thinking about asking guest users to post a name when writing a comment.
How do I add a new field to the comment table in the database the best way? Using a query in the update section? Probably not...
Posts: 32509
nope, not like that.
cd modues/comment/classes/
open GalleryComment.class in an edit
add commenterName or something like that as a new member. see commenterId etc.
the php comments above the commenterId is more than just a comment, it's XML. add such XML also above your commenterName and change it accordingly.
at the top of the class, change the schema version from 1.1 to 1.2
cd modules/comment/classes/GalleryStorage/DatabaseStorage/schema/xml-src/
copy A_GalleryComment_1_0.xml to A_GalleryComment_1_1.xml
change the file according to your change, there are other examples in modules/core/classes/GalleryStorage/DatabaseStorage/schema/xml-src/
cd modues/comment/classes/
gmake
modules/core/classes/GalleryStorage/DatabaseStorage/schema/
gmake
Posts: 5
I've tried to install it, but in the Site Admin module its tells me it requires Module API 2.2, where i have 2.0. I've upgraded my gallery to 2.1, but its still giving the same error. How do i upgrade my Module API to 2.2? Can't find proper documentation on upgrading the Module API. Can you help me on this one?Thx
Posts: 32509
get the latest nightly snapshot.
downloadpage -> g2 nightly snapshots from jmullan
Posts: 5
Thx!One more question. I've downloaded the latest nightly snapshots from jmullan. I have a slightly modified gallery, do i need to upload all of the files, or only some of them to upgrade my module API to 2.2.
Posts: 32509
you better should upload all files.
and your modifications shouldn't be in any official .tpl file. move your customizations into templates/local/ folders or into your own themes.
and if you need to customize .inc / .class files, make a list of your changes such that you don't forget to reapply them. or better move them into your own modules.
Posts: 5
Ok, everything set and done.
I created an new fresh and clean install of gallery2 using the latest nightly snapshots from jmullan.
But when trying to upgrade the comments module in the Site Admin area, i get the following error:
Error Detail -
Error (ERROR_BAD_PLUGIN) : Unknown module version 1.0.4
* in modules/comment/module.inc at line 153 (gallerystatus::error)
* in modules/core/classes/GalleryModule.class at line 175 (commentmodule::upgrade)
* in modules/core/AdminModules.inc at line 85 (commentmodule::installorupgrade)
* in main.php at line 201 (adminmodulescontroller::handlerequest)
* in main.php at line 88
* in modules/core/classes/GalleryEmbed.class at line 155
* in index.php at line 132 (galleryembed::handlerequest)
* in /home/httpd/vhosts/techno-kitty.com/httpdocs/modules.php at line 68
System Information
Gallery version 2.0.1+
PHP version 4.3.8 apache2handler
Webserver
Database mysql 4.0.25-log
Toolkits ImageMagick, NetPBM, Gd
Operating system Linux us1.1-eurohost.com 2.4.22-1.2199.nptl #1 Wed Aug 4 12:21:48 EDT 2004 i686
Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; nl-NL; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
The current comment module version is 1.0.4.
Anyone who can help me fix this one?
Posts: 25
Hi SanderT,
sorry, my fault. Please change the following in the file modules/comment/module.inc beginning at line 118:
to
This happend because I was not using the latest CVS when starting my modifications. Hope this works.
Edit: Updated the diffs and files above.
Posts: 5
Thx, got it upgraded now. And i can see the link to the latest comments in the sidebar, but to bad its not working yet. I get the following error, when clicking on Show Latest Comments:
Error (ERROR_MISSING_OBJECT) : Missing object for 0
* in modules/core/classes/GalleryStorage/DatabaseStorageExtras.class at line 1780 (gallerystatus::error)
* in modules/core/classes/GalleryStorage/DatabaseStorageExtras.class at line 321 (databasestorageextras::_identifyentities)
* in modules/core/classes/GalleryStorage/DatabaseStorage.class at line 343 (databasestorageextras::loadentities)
* in modules/core/classes/GalleryStorage.class at line 121 (mysqldatabasestorage::loadentities)
* in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 82 (gallerystorage::loadentities)
* in modules/core/classes/GalleryCoreApi.class at line 2187 (galleryentityhelper_simple::loadentitiesbyid)
* in modules/comment/ShowAllComments.inc at line 142 (gallerycoreapi::loadentitiesbyid)
* in modules/core/classes/GalleryTheme.class at line 689 (showallcommentsview::loadtemplate)
* in modules/core/classes/GalleryView.class at line 312 (matrixtheme::loadtemplate)
* in main.php at line 335 (showallcommentsview::doloadtemplate)
* in main.php at line 88
* in main.php at line 81
Any thoughts?
Thx in advance.
Posts: 25
Sorry, no idea. I don't get the same error. I installed a new, clean version of the latest CVS and uploaded my changed files to see if there is a problem but it works and I don't get your error. Did you try cleaning the template cache?
Did someone else try my modifications and got it running?
Posts: 1
I was able to install the updated module on the 2.0.1 release by changing the "Module" module requirements back to 2.0 and it works beautifully. I just want to thank you for your hard work on this HIGHLY requested feature.
Works beautifully!
Posts: 5
Got it working now!
TablePrefix (g2_) and columnPrefix (g_) needed to be gallery defaults. I had customized prefixes and that didn't work out. Now its up and running and i'm already receiving positive feedback from users. It was a kind of let down, that this feature was missing, when i migrated Gallery 1 to Gallery 2.
Of course credits go to jschmittat for his work on this feature, and valiant thanks for all the help.
Posts: 8601
This code is now integrated into comments module, thanks for the contribution!
Changes I made:
- check for comment.view permission before showing link for ShowAllComments
- don't check userId request param (was that for testing?) when checking for anonymous user
- make sure we're using validation plugins in AddCommentController before loading them up
- removed isDefault in SiteAdminView (unused)
- removed default.* parameters ("reset" in site admin views means reset to last-saved values)
- in site admin check if there are any available validation plugins
- ShowAllComments was loading all comments in the db and filtering out parent and max# to show and permissions check in php.. I put this logic in the query.
- include Comment.tpl instead of duplicating; removed AllComments.tpl
I also added an $offset parameter in the helper function, in case someone would like to add pagination to the comments view (ie to see the next 10 or whatever).
Posts: 25
Thank you, mindless! I am very happy that you reviewed the code and integrated it into the comments module.
About the loading of the comments: I am very curious to see how you solved it, as I was not able to do it. Well, that's the difference to a gallery professional
Looking forward to the next CVS files...
Posts: 68
sweeet, thanks guys! I will have to try this soon.
Posts: 8601
Forgot to mention, I went ahead and added pagination so you can access all the comments on multiple pages now.
Posts: 25
I would like to add the new phrases and words used in this modification to the German localization file. Problem: I am working on a windows pc. Can anyone tell me if there is a possibility to run gettext and make on a windows pc?
Posts: 32509
there are gnu utils and binutils for windows.
or you could get cygwin (a linux emulator for windows) and in the cygwin installer, make sure to select make etc.
Posts: 9
BTW, sorry for the ignorance but may I ask how do I update an existing and installed module in Gallery? I want to use this new feature but I'm afraid I might screw up my existing install of Gallery.
Do I disable and uninstall the existing comment module first?
Thanks.
Posts: 32509
just extract the new nightly snapshot of g2 over your existing g2 and upgrade.
if you just want to upgrade a specific module, extract the new module over the old and upgrade the module in site admin -> modules.
sometimes a module depends on the latest g2 (core module) version, then it will show a message and you can't upgrade until you upgraded g2.
FAQ: How to upgrade Gallery2?
Posts: 52
Hello,
I am really happy with this module, this was the one feature I missed one the new Gallery! There's just one problem i have, when i'm logged in as "admin" i can see the link: View Latest Comments on the MainPage, but when i'm logged in as a normal user, or guest, i can't see the link on the main page, but in the sub-albums i can see it. Do you have any idea what to do?
thanks
Posts: 8601
check permissions on your root album. sounds like Everybody group doesn't have view comments permission.
Posts: 23
Is the attached file in this post the latest version of this module or is there a place to download it? The gallery website still shows it as version 1.0.0
Posts: 8601
current CVS or nightly snapshot has this feature.
Posts: 1
hey! thanks everybody for making this really nice update to the comment module. the lack of this function was the reason sticking with coppermine. it's time to change ;)
thanks again!