Error adding functionality to comment module

nivekiam
nivekiam's picture

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:Parse error: parse error, unexpected T_VARIABLE, expecting '(' in /usr/www/users/path/to/g2/gallery2/modules/comment/module.inc on line 134

If I use this code if (($params['albumComments'] = 1) && (GalleryUtilities::isA($item, 'GalleryPhotoItem'))) {
Then the add comment option never shows up for an album. Even if I've gone back to the admin interface and remove the check so I can allow comments at the album leve;.

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.... :-?

AttachmentSize
comment.zip5.89 KB
 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Mon, 2005-07-04 03:57

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.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2005-07-04 17:43

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.