Error adding functionality to comment module
nivekiam
Joined: 2002-12-10
Posts: 16504 |
Posted: Mon, 2005-07-04 00:44 | |||
I figured I'd finally have a go at trying to edit a module. I saw this thread http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=32262 and figured that should be pretty easy to do. I've created a site admin interface for the Comment module to have this option. However, I can't seem to get everything to work right. If I use this code if $params.albumComments && (GalleryUtilities::isA($item, 'GalleryPhotoItem')) { I get this error: If I use this code I know it's something stupidly simple. I'm attaching the few files I've created and the edited module.inc and a diff to easily see what I've changed. I do realize there's some cleanup I need to do to the admin interface, but I just wanted to get the code working first. I also realize part of my problem is my lack of familiarity with Smarty, PHP, the G2 code base and well OO programming.... :-?
|
||||
Posts: 8601
Use == for comparison.. (= is for assignment), or simply:
if ($params['albumComments'] && GalleryUtilities::isA(.....
actually, shouldn't this be || ? ie, show the link if album comments are turned on OR the item is a photo.. also, consider whether GalleryPhotoItem or GalleryDataItem is more appropriate.. otherwise you need to turn on "comments for albums" in order to add comments on movies.
Posts: 16504
mindless, thank you. I made your suggested changes. Then found a few other errors and after beating my head against the wall for a few hours figured them out.
I now have an option to allow or disallow comments for albums. However, if you already have comments for albums it won't hide them. I'm not sure where to make that change. I've looked and tried to edit and never could get it to change the behavior.
If you think this would be a useful addition let me know and I'll post a patch to SF. Though I gather G2 is in feature freeze right now so it's probably going to have to wait if I'm correct in my understanding.