add "view this albums comments" for each album in
cersa
Joined: 2003-01-12
Posts: 11 |
Posted: Thu, 2003-07-10 02:42 |
ok.. it has come down to me begging for help. All I want to do is add a link that allows anyone to view the comments in a album from the main gallery page.. just like the link on this webpage. http://www.tnatech.com/gallery **this is not my webpage and I hope I don't get in trouble for adding it here for reference** I just wanted to show everyone, exactly what I am looking for. If I am not supposed to do that ... someone please delete this post. Anyhow... I want to add a this option for my viewers. I searched the forums and did some research... honest... and I seen lots of options.. . but not the one I am looking for. If anyone has the time and knowledge to assist me, that would be super cool. :D Thanks, Angel |
|
Posts: 314
Hey Angel!
I like your site, especially the girlish looks ;)
Anyway, what you want to do isn't that hard. Normally the comments (view_comments.php) are only viewable for admins and album owners. If you want to change that, open view_comments.php and find the line:
if (!$gallery->user->isAdmin() && !$gallery->user->isOwnerOfAlbum($gallery->album)) {
This is line 36 in Gallery 1.3.3 or line 39 in Gallery 1.3.4. Replace this line byif (!$gallery->user->canReadAlbum($gallery->album)) {
Now the comments page can be viewed by all users who can read the album.To get a link on the main page of Gallery, like in the example you mentioned (you can _always_ link to websites, that's the way the internet works), you'll need to open albums.php and find
This is line 240 in Gallery 1.3.3 and line 253 in Gallery 1.3.4. Between these two lines you should add the code
I haven't tested the changes to albums.php, so let me know if they don't work. Good luck.
Posts: 11
Hi! Angel here. Thanks for responding to my post. It means a lot that people like yourself with the knowledge you have helping out the less fortunate! I followed your instructions.... I messed up along the way. The link is there, but pointing to a dead end. I listed what I did below.
step 1 - in view_comments.php
I changed this code:
if (!$gallery->user->isAdmin() && !$gallery->user->isOwnerOfAlbum($gallery->album)) {
to this code:
if (!$gallery->user->canReadAlbum($gallery->album)) {
Step 2 - adding the link - in albums.php
I found this code:
<br>
<?php if (strcmp($gallery->app->default["showOwners"], "no")) { ?>
and inserted this code:
<span class="fineprint">
<a href=' . makeGalleryUrl("view_comments.php", {$tmpAlbumName}) . '>[View This Albums Comments]</a></span>
<br>
making it look like this after I added:
<br>
<span class="fineprint">
<a href=' . makeGalleryUrl("view_comments.php", {$tmpAlbumName}) . '>[View This Albums Comments]</a>
</span>
<br>
<?php if (strcmp($gallery->app->default["showOwners"], "no")) { ?>
So what do you think?
Thanks for visiting my website!! More girlish looks to come! :D
Angel
Posts: 314
The problem is in this line:
<a href=' . makeGalleryUrl("view_comments.php", {$tmpAlbumName}) . '>[View This Albums Comments]</a>
There's some code in here, but I forgot to put it between tags, so try changing it to
<a href='<?php makeGalleryUrl("view_comments.php", {$tmpAlbumName})?>'>[View This Albums Comments]</a>
and see what happens. Alternatively, you can try
<a href='view_comments.php?albumName=<?php $tmpAlbumName ?>'>[View This Albums Comments]</a>
Posts: 11
thanks for all of your help.
I just can't seem to get it working.. and I am making things worse getting errors...
I probably should stop while I am ahead... before gallery explodes on my desk top!!
Thanks again,
Angel
Posts: 11
Another day... another attempt! (only one error remains)
I tried you ideas..
When I click on the "view this albums comments" it brings an error of:
Fatal error: Call to a member function on a non-object in /home/angel/public_html/Gallery/classes/User.php on line 90
in album.php the code this is the code:
<br>
<span class="fineprint">
<a href='view_comments.php?albumName=<?php $tmpAlbumName ?>'>[View This Albums Comments]</a></span>
<br>
I looked at the user.php and line 90 this is the code:
function canReadAlbum($album) {
if ($this->isAdmin()) {
return true;
Its going to be a great day!
:D Angel
Posts: 314
As you can see, I'm not really a PHP programmer, and I usually work with trial-and-error ;)
In your page, the albumName doesn't get printed. Why? Because I forgot the print command :roll:
So try changing
<a href='view_comments.php?albumName=<?php $tmpAlbumName ?>'>[View This Albums Comments]</a></span>
to
<a href='view_comments.php?albumName=<?php print $tmpAlbumName ?>'>[View This Albums Comments]</a></span>
Have a nice day!
Posts: 27
Hi Angel...
Try this (be sure to start with a fresh set of these files so you're sure you aren't mixing up various edits)...
In view_comments.php (on line 39 in Gallery 1.3.4)...
Change this:
if (!$gallery->user->isAdmin() && !$gallery->user->isOwnerOfAlbum($gallery->album)) {
To this:
if (!$gallery->user->canReadAlbum($gallery->album)) {
...so that everyone has rights to view all comments.
Next...
In albums.php (on line 327 in Gallery 1.3.4.)...
Look for:
<br><br>This album has been viewed <?php echo pluralize($gallery->album->getClicks(), "time", "0")?> since <?php echo $gallery->album->getClicksDate()?>.
And add this line immediately after it:
<br><br><a href=<?php echo makeGalleryUrl("view_comments.php", array("set_albumName" => $tmpAlbumName))?>>[View Comments]</a>
This will create the "View Comments" link on the main Gallery index page.
Lastly...
In commentboxtop.inc in the layout folder (on line 20 in Gallery 1.3.4)...
Change this:
<?php if ($gallery->user->isAdmin() || $gallery->user->isOwnerOfAlbum($myAlbum)) { ?>
To this:
<?php if ($gallery->user->canReadAlbum($gallery->album)) { ?>
...to enable visitors to see and use the "View Comments In This Nested Album" links if you have any nested albums.
Upload those 3 files and you should be good to go! I use this same hack on my galleries and it works like a charm.
Hope this helps.
Posts: 11
Okey dokey! I got it working now. :D
BorgKing - I did the last thing you suggested, and I received the error still.
KenB also left me some options and I got the view comments working with that. Yippieee! However now I have the IP addresses next to the comments which I don't like much. So I am off to research that.
If you know how to remove the IP let me know, that would be the icing on the cake!
Thank so much for your help guys! Its is much appreciated. Go take a look at the gallery if you like http://www.totallyangel.com/Gallery/ you can click the view comments link and it works!! Thanks to you guys!
:D Angel
Posts: 314
Yeah, sorry I couldn't get the code in albums.php working. Thanks KenB!
As for the IP-address, you'll have to look up in the code of view_comments.php where the IP address is inserted (I have been away from my regular computer the last few posts, so I couldn't look up the Gallery code). But anyway, find where the IP address is inserted, and put it between
if (!$gallery->user->isAdmin() && !$gallery->user->isOwnerOfAlbum($gallery->album)) {
and}
Good luck with that!
Posts: 27
The IP address only shows when you are logged in as admin. Regular visitors won't see the IP address.
Posts: 11
ok, here is the scoop.
BorgKing ~ I looked in view_comments.php for ip address code... I am not sure what I was looking for.. but nothing in there said IPaddress... when I find the code in view_comments.php ...... then I put that code from view_comments.php between
if (!$gallery->user->isAdmin() && !$gallery->user->isOwnerOfAlbum($gallery->album)) {
and }
which is found inside of albums.php .. right? Because I did not see it in view_comments.php
phew , this is confusing.
KenB ~ go to my gallery at http://www.totallyangel.com/Gallery viewers can still see the ip address. ?? I seems admins are only supposed to see it... but if you click on it there it is..
What if I tried upgrading? I have 1.3.3 now, if I upgrade would that fix the IP address thing? I don't think it would since I added the view all comment thing .. ??
Its all good!
Angel
Posts: 27
I see what you are talking about now...
The file that does this is commentbox.inc in the layout folder.
Look for this: (line 5 for Gallery 1.3.4.)...
And change it to this:
From: <?php echo $comment->getName() ?> (<?php echo $comment->getDatePosted() ?>)
Hope that does the trick!
P.S. This will remove the display of the IP address even for admins, but only on the View Comments pages. The IP address will still be displayed (only for admins) on the full-size pic pages where the comments are displayed below the pic.
Posts: 11
KenB
It worked like a charm. Thanks so much for assisting me in changing my gallery.
You too BorgKing! Thanks for all of your help!
:D Have a wonderful weekend!
Angel
Posts: 21
Has anyone gotten this mod to work with 1.4 RC2? Still is only letting the admin see the mod, and I don't think it's bringing up the comments on the sub-album view page correctly.
UPDATE (9/4/03): I had to open and close the scripting tags to be able to add the mod in albums.php in the correct place, so now all users can see it. I'm still not sure if this is working as intended though. It'd be nice if there was an additional indicator on the sub-albums page IF there are comments available, or the time/date of the most recent comments... visible on the sub-album page.
Posts: 135
I have all this working on my gallery http://ourphotos.org (vs. 1.4) but still only admin can see the link.
Can someone give the code to change so that everyone can see that link not just the admin.
***As an aside - I created a link <a href="http://ourphotos.org/view_comments.php?set_albumName=wendy1">[ View all
Comments ]</a>
In the album description that is a good quick fix, but I hoped to have that come up automatically.
Thanks
Posts: 21
Chris, I'm not quite clear about your last post.
What link is visible only to the admin for your site? Is it the link at the top-right when you're viewing an album?
Posts: 1
There are some differents in 1.4-RCx, cause 1.4 is supporting multilanguage. In 1.4-RC3, albums.php shoulde be modified like below.
Find this...
And add this line after it:
others' are just like KenB's setting...
Try it!
--
I'm from Asia, so excuse for my broken English...:P
Posts: 21
It'd be nice to have an indicator on the sub-albums page that shows which albums had comments available, rather than just the ability to blindly "View comments for this nested album".... perhaps even just adding the * on the sub-album page to indicate if there are comments available in a particular sub-album. Anyone have ideas of how to do this?
Posts: 3473
upgrade to 1.4.1-b74 or greater.
Just be adding this to the main gallery source.
You can also have last comment date instead of the star if you like.
Posts: 21
Thanks Joan,
I wasn't aware that these features had been implemented in 1.4.1. Guess I'll have to finally learn how to use CVS.
Posts: 21
Well I just set up my CVS client, but the version of Gallery that is showing is 1.4.1-b64. What am I doing wrong?
Posts: 3473
ODiN,
It wasn't in 1.4.1 when you made the request
And CVS: sorry about that, the anonymous server lags the writable server by a substantial margin. Keep checking and also keep an eye on http://www.jpmullan.com/galleryupdates
Posts: 21
Well that's awesome then! Thanks for all the help Joan. I'll keep my eyes peeled...
Posts: 8
thank you KenB and BorgKing very much for this hack!
it worked immediatly on my site! www.kingkluge.de
Posts: 27
hi, i followed your introctions to make the "view comments" public...
but my problem is, in some gallerys it work inother it doesn't
here is a screenshot:
[img]http://members.e-server.at/felix/felix/gallery.jpg[/img]
greats,
quadris
Posts: 31
hi,
i have made the changes, and while logged in as admin it works great.
as soon as I am anonymous, I get the follwing error:
Fatal error: Call to a member function on a non-object in /home/www/de.pgt/html_privat/modules/gallery/classes/User.php on line 240
i am not sure where it comes from. testing on today cvs checkout...
Posts: 9
I had quite a bit of trouble getting this to work with the code provided here. So i just wanted to post the way i got it to work...maybe this method will help those who are still getting errors.
This first step was provided by BECKETT, i took part of his code:
1) Everyone see the link:
In albums.php , find this code:
Code:
This was the exact link that I moved out of the admin section
<?php if (!strcmp($gallery->album->fields["public_comments"],"yes")) { ?>
<a href=<?php echo makeGalleryUrl("view_comments.php", array("set_albumName"
=> $tmpAlbumName)) ?>>[<?php echo _("view&comments") ?>]</a>
<?php } ?>
Move the link line out of the "admin" if {} block.
Just paste it lower in the code and it will pop up on the main page.
2) Then Follow This Code Provided By KenB
In view_comments.php (on line 39 in Gallery 1.3.4)...
Change this:
Code:
if (!$gallery->user->isAdmin() && !$gallery->user->isOwnerOfAlbum($gallery->album)) {
To this:
Code:
if (!$gallery->user->canReadAlbum($gallery->album)) {
...so that everyone has rights to view all comments.
3) Last I followed this code by KenB again:
In commentboxtop.inc in the layout folder (on line 20 in Gallery 1.3.4)...
Change this:
Code:
<?php if ($gallery->user->isAdmin() || $gallery->user->isOwnerOfAlbum($myAlbum)) { ?>
To this:
Code:
<?php if ($gallery->user->canReadAlbum($gallery->album)) { ?>
...to enable visitors to see and use the "View Comments In This Nested Album" links if you have any nested albums.
And now it should work....i tried all the diff codes in this post but this was the combination that worked for me. Hope this helps someone.
To see it in action check my site: Http://walkingwithsharks.com
Posts: 3474
agilos:
Glad you got it working, and thanks for the detailed how-to!
-Beckett (
)
Posts: 6
Got this to work thanks all! yay!
quick follow-up: did anyone figure out how to show the "view_comments" link only if there are some comments?
Posts: 15
am working on a comment counter so that you 'll see a number which indicates the total comments inside of a albums.
I'll post it here as soon as I get it done.
( it's gonna be after my final exams though ... which is within 2 days )
Posts: 9
efurban,
I would really like to see that work. I have been looking for a way that shows the total number of comments for each album on the "view all comments" page. This feature would be helpful. Just letting you know of my interest as well im sure others would find this useful! Thanks!
Posts: 15
*** update: this heck is also work for gallery_1.4.2-b74 -- tested ***
as I promised, here is the code and steps :
/**
* hack: recursively count the total number of comments in a album (gallery)
* Author: Travis Wu
* Email:
* Date: Nov 26, 2003
* the code below partially are from the posts in this forum, thanks for
* whoever helped.
*/
this will give you:
- view comment link on the right side of
"Last comment xx/xx/xxxx." so that everybody can
check the comments.
- total number of comments on the right side of [View]
- total number of comments in each nested album
- the view comments link shows up when the album has comments > 0
steps:
1) gallery/layout/commentboxtop.inc
find
<?php if ($gallery->user->isAdmin() || $gallery->user->isOwnerOfAlbum($myAlbum)) { ?>
replace it with :
<?php if ($gallery->user->canReadAlbum($gallery->album)) { ?>
find
<br><a href="<?php echo makeGalleryUrl("view_comments.php", array("set_albumName" => $myAlbumName)) ?>">[<?php echo _("view comments for this nested album"); ?></a>
replace it with
2) gallery/view_comments.php
find
if (!$gallery->user->isAdmin() && !$gallery->user->isOwnerOfAlbum($gallery->album)) {
replace it with
if (!$gallery->user->canReadAlbum($gallery->album)) {
3) gallery/albums.php
find
print lastCommentString($lastCommentDate, $displayCommentLegend);
add the following after it:
4) gallery/classes/Album.php
find
add the following after it
done!!
I am using the newest version of Gallery (v1.4.2-cvs-b30) from CVS.
however, it should work w/ 1.4.1 and other version as well.
If you have any problem, let me know.
Posts: 21
Travis,
Thanks for working on this! This is exactly the type of functionality I think Gallery should have built in. Good work!
Posts: 9
Efurban,
Good job on the added count feature though I cant find where Im supposed to apply step 3. That piece of code doesnt seem to be in Gallery v1.4-pl2. Let me know if its an oversight by my part.
Thanks
Posts: 21
agilos,
I may be wrong, but I'm pretty sure the Last Comment Date feature wasn't added until 1.4.1.
Posts: 15
Thanks eveybody for reply me back. :P
did you solve your problem agilos ?
You probably wanna update your gallery to a newer version .
well, it's not hard to get it working for your version as well.
Let me know.
Posts: 9
Thanks for the the info Odin and Efurban, I just downloaded Gallery 1.4.1. Just out curiousity before I upgrade, do happen to know what I would need to add to 1.4-pl2 to get step 3 to work. If its to much trouble, dont sweat it i'll just upgrade sometime next week.
Posts: 9
Well thanks efurban but i have 1.4.1 gallery from 25th November ( the one i was pointed out to download )
" Fatal error: Call to undefined function: commentrecursivecount() in C:\Program Files\Abyss Web Server\htdocs\albums.php on line 421 "
I did all the steps ( 1 , 2 ,3 , 4 ... ) and i see red star leading me from album to sub album and then to image that has comment. but nothing like you mentioned. Can you please see what's up with our version (1.4.1) ?
When i remove what you added in step 3 ( gallery/albums.php ) i can see my all my albums and red star leading saying " this item contains comments". When i put it in what you added in step 3 , i get that error and i loose some albums in main gallery.
thanks for help !
Posts: 70
Has anyone got this to work with Gallery 1.4.2 yet? Please let me know, this hack is great and I would like to use it with the newest version. Thanks!
Posts: 70
Nevermind, I figured it out
Posts: 70
Does anyone know what I need to change to get this to work with gallery 1.4.3? I am getting an error:
Parse error: parse error in /home/mydamnpa/public_html/pics/layout/commentboxtop.inc on line 24
This is what line 24 reads:
<br><a href="<?php echo makeGalleryUrl("view_comments.phpbr><a href="<?php echo makeGalleryUrl("view_comments.php",array("set_albumName" => $myAlbumName)) ?>">[<?php echo _("view comments for this nested album"). " <font color=\"ff0000\">(".$myAlbum->commentRecursiveCount().")</font>"?>]</a></span>
This worked fine for version 1.4.2. Can anyone help with this?
Posts: 70
Can anyone help me with this please?
Posts: 27300
midkiff,
Looks to me like you need to go over step #2 again. Line 24 should not look like that. You have makeGalleryUrl("view_comments.phpbr><a href="<?php
You are missing stuff between the php & br (bold above)
Dave
Posts: 70
Thanks! I guess I need to pay more attention next time I am copying and pasting! Sometimes it just takes another set of eyes checking it out.
Posts: 27300
midkiff,
I have fat fingers too!
Posts: 52
Hi guys,
i love this simple and usefull hack but i can't get it working with my 1.4.3 gallery. I've changed everything and double checked but i can't see neighter results nor errors
www.mcgrelio.com/bin/gallery
Does this hack work with gallery 1.4.3?
Thx
Posts: 27300
mcgrelio,
Looking at your site it looks like you don't have the * (at the bottom of the page) when comments are entered. Have modded albums.php before?
If you look at albums.php, where you did the change for this mod, two lines up there is a line
if($gallery->app->comments_enabled == 'yes') {
Your mods will not work unless you have comments_enabled....So in config.php look for and verify;
If that does not work post back.
Dave
Posts: 52
Commnents were enabled on my gallery but comments_indication was set to "photos" and not "both". After having changed that to "both" it works.
Now I want the "[" and the counter to be binded to the css. Those characters are red while i want them (except for the "*") looking like the css tells.
Any ideas?
BTW... THX A LOT!
Posts: 52
Ok i got it, it was simple. I deleted the <font> tag in the code ;)
Now i have 2 other questions:
1. is it possible to see only the albums and photos with comments excluding those containing no comments? how?
2. obviously the hack shows also the hidden albums, though nobody can enter and watching the photos without the right permissions, but, is it possible to completely hide them?
Thx, cya ;)
Posts: 27300
If you look on your page your album called upload does not have any comments. So it does not have a link to the comments page.
Or do you mean you want to have a page with just comments? If so there is a great mod called stats.php. It will allow you to have comments sorted in order as well as most comments etc... Check it out:
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=13560&highlight=stats
I don't have many hidden albums so I will have to experiment. But the mod only shows the link if the user can view the album
if (!$gallery->user->canReadAlbum($gallery->album)) {
Can you explain a bit more. You could change the code to say logged in if you wish.Dave