Hybrid theme: how 'Add Comment' from photo page?
|
rick7
Joined: 2005-03-02
Posts: 168 |
Posted: Mon, 2006-01-09 11:55
|
|
Hi, I love the Hybrid theme but can't see how to add a comment to a photo from the photo page. Thanks for any help with this. |
|

Posts: 8601
hybrid is intended more as an image viewer, so it doesn't have easy access to item links. as is, you need to show the sidebar and click "show item links" (or just hit ctrl-up) and then you can click the little box near any thumbnail and find the "add comment" link. the link is not available while actually viewing the photo.
the reason it is this way is that i don't use any item links that are "user actions" like add comment, add to cart.. in my setup only admin functions like "edit photo" are there, so i hide them most of the time and just show the icons for item links when i'm editing an album.
you could modify hybrid to make a more prominent link of course.. maybe 'add comment' in the title bar along the bottom while viewing a photo..
Posts: 168
Thanks; most of my viewers have told me they're not ready to add a comment from just viewing the thumbnail and need to see the larger picture. So I might have to learn a little PHP and modify this baby myself. Not sure where to fit an 'Add Comment' since the title occupies the bulk of that bottom title bar. Any thoughts about this? I guess my preferred solution would be a button near one of the groups of buttons on the left or right.
Is this all in PHOTO.TPL?
The thing I really appreciate about this theme is how the photo dynamically expands to fit the screen.
Posts: 8601
hybrid doesn't have a photo.tpl; this is all in hybrid.tpl
perhaps make an icon/button for that bar.. won't take up much space that way.
Posts: 168
Thanks; I'll take a look.
I'd also like to make another change for viewing photos: when 'Hide text' is On I'd like to show the Summary rather than the Title. Would that be possible? And if so would the code also be in PHOTO.TPL? Thanks much.
Posts: 8601
um, hybrid still doesn't have a photo.tpl; this is all in hybrid.tpl
not sure exactly where you want to change, but anywhere in the tpl that you find $theme.item.title you can change it to $theme.item.summary, and $it.title (titles of child items) you can change to $it.summary
Posts: 168
Thanks VERY much. I'm trying to get the summary to display in the photo page where currently the title displays. After changing $theme.item.title and $it.title, now I DO get the summary where the title used to display at the bottom of the Photo page, but I'm ALSO getting the summary displaying where the title used to display in the ALBUM page as well (so it displays twice).
Any way to get the summary-in-the-title field to be only for the photo page?
Sorry to bother you with this, but I really like this theme. Thanks for any help.
Posts: 8601
yes, but it need an additional change.. the text displayed in the photo view is actually copied directly from the text in the album view. you'll need a new (hidden) source of the text data for the photo view.
find this:
<span id="title_{$it.imageIndex}" class="giTitle"and take out the id= part (now just <span class="giTitle")
This id is what is copied to the photo view.
find this:
{$it.title|markup}</span>(you may have changed this to $it.summary -- change it back)
just below this line add:
<span id="title_{$it.imageIndex}" style="display:none">{$it.summary|markup}</span>that should do it.. will you be sharing a link to your site when it is ready?
Posts: 168
FANTASTIC! Thank you immensely. Works perfectly. One more thing I'd like to accomplish: I'd like to use a smaller font for this new 'Summary' text on the title bar, such as what's used for the Summary text on the album page. Might you be able to point me in the right direction for that?
I certainly will post a link to my Gallery when I get this done. The project that is most important to me is to get an Add Comment icon down there on the right side of the title bar. That's my task for the next couple of days. I'm a SQL programmer and I should be able to get the hang of PHP fairly quickly (fingers crossed).
Your help is most appreciated.
Posts: 8601
find:
div#title {
in theme.css and add a font-size setting in that block.
happy to help.. glad to hear of someone else using my theme.
Posts: 168
Thanks much--I inserted a font-size and font-weight setting and it looks pretty good. I was hoping to mirror exactly the font of the 'summary' text on the album view -- what settings would I use for that?
I wonder if you could also help me out with my original desired modification: adding an 'Add Comment' feature via an icon on the right side of the title bar on the photo view. I've been reading the template documentation and have copied code from elsewhere, but am still spinning my wheels. Any chance you have some code for this that I could use? Much appreciated, as always.
Posts: 8601
view the html source of a page, find some text you want to match.. look at the class and/or id of the containers for that text.. look in theme.css to see what settings are used. if you have web developer extension for firefox/mozilla there's an option to just click on something and see the css that affects it.
for add comment.. search for id="tools_right" in hybrid.tpl. just after that line try adding:
<a href="#" onclick="this.href=document.getElementById('addcomment_'+image_index).innerHTML"><img src="{$theme.themeUrl}/images/addcomment.png" alt="{g->text text="Add Comment"}" width="18" height="18"/></a>then find <td class="giDescription"> and just below it add:
<span id="addcomment_{$imageIndex}" style="display:none">{g->url arg1="view=comment.AddComment" arg2="itemId=`$it.id`"}</span>then add the addcomment.png file in the images dir and give it a try..
Posts: 168
Thanks...but after inserting this code the 'add comment' feature doesn't work. The icon displays nicely (I'm using add_comment.gif) but when you click on it nothing happens.
I'm attaching my HYBRID.TPL -- maybe you could take a look at it and see what's missing? Thanks much.
Posts: 8601
oy, you started from hybrid.tpl rev 1.4? the current rev is 1.13... i've done quite a bit since 1.4
Posts: 168
Hmmm...don't know where to get a newer revision. From the Gallery home page, I just clicked on Downloads, then Gallery 2...Latest stable release: ....Themes, and I get the file g2-theme-hybrid-1.0.0.zip which is rev. 1.4, just as I have. Thinking you might have posted something to the forums, I searched there and didn't find anything either.
Posts: 8601
nightly snapshots or CVS....
anyway, change {$imageIndex} to {$it.imageIndex}
and in the {g->url.... add htmlEntities=false just before the }
Posts: 168
Thanks. We're talking about Gallery 2.1, yes? I'm a bit nervous about installing a not-officially-released version myself since the web server world is VERY new to me (my web host installed Gallery originally), but I'll ask them about it.
In the meantime, I made the above changes and it now loads up the Add Comment screen, but when I click on SAVE it doesn't save but retains the same screen. It reminded me of a similar situation a while ago when some posted code to add 'Add Comment' to another theme needed to have [arg 3="return=true"] added to the g->url. Thrashing out blindly, I tried that here but to no avail.
Any thoughts? I'm attaching my old HYBRID.TPL again for your review. Much appreciated.
Posts: 168
Postscript an hour later: I just noticed that when I click on the Save button and it doesn't close the Add Comment screen, it IS saving my comment, but as a Gallery-wide comment on the top-level album rather than on the individual photo.
Maybe this is related to my using the 2.0.2 release.
Posts: 8601
Ok, we can resolve the problem with entities in the urls by making <a> items to copy from instead of <span>. Also you are correct about adding the return url in the links.
Use these code bits:
<a href="#" onclick="this.href=document.getElementById('addcomment_'+image_index).href"><img......and
<a id="addcomment_{$it.imageIndex}" style="display:none" href="{g->url arg1="view=comment.AddComment" arg2="itemId=`$it.id`" arg3="return=true"}"></a>Regarding the latest code.. we do a reasonably good job of keeping CVS stable. If you get the current nightly snapshot and install it for use in development of your site then you'll have a theme ready to use with 2.1 when it comes out (target is end of february).
Posts: 168
**sssshhhhpop!!*** That's the sound of a bottle of champagne uncorking. Fanstastic. It's now working. This is going to be great to have.
OK, knowing that the nightly builds are pretty stable, I will ask my web host to install 2.1. Will I have to move a copy of the new HYBRID.TPL into /templates/local and make these mods again to this new template? In any case, I am curious to see what you've done since rev 1.4.
Couple of things I've noticed:
(1) For some reason, the bubble text of the 'comment' button doesn't display. Wonder what I'm doing wrong?
(2) After the comment is saved, we're taken back to the album page rather than the photo.
Thanks for all this.
Posts: 8601
backup both your tpl and the original 1.4 revision.. then you can do
diff -u hybrid.tpl_1.4 hybrid.tpl_yoursto get a report of your changes; then you can apply the same to the current hybrid.tpl. For the changes you've made I think this process should be pretty easy.
1) add a title attribute on the <img> to get the mouseover text.
2) hm.. that's a little tricky. hybrid doesn't really have separate "pages" to show photos.. the viewer is dynamic html/javascript that appears on top of the album view.. so when we add arg3="return=true" in the g->url we get the current url, which is for the album. now, if you make an url with itemId={itemId for a photo} hybrid DOES know how to load the page for that album and then popup that particular image when the page loads.. so if you can get the right return url, it's possible.
Posts: 168
I added a title attribute to get mouseover text and it works great. I'm totally new at this, but I'd thought that this segment would insert mouseover text:
alt="{g->text text="Add Comment"}"
No? I added a title= line and it works, but what does "alt=" mean? Well, now I know I have to study the Smarty template language so I guess I'll get it all figured out soon enough. Figuring out how to get {itemId for a photo} is going to take some bit of learning for me, so off I go...
For anyone else who's been following this thread, I think Hybrid one of the truly excellent themes not the least because of its ability to dynamically size the image to fit available screen space. Anyone who'd like to see my Gallery modified to (1) display the Summary text rather than Title in the title bar of a photo page and (2) be able to click on an icon to add a comment from the photo page, I'm at http://www.earthdreaming.net/gallery.
Posts: 168
Mindless -- now that I have commenting ability from the 'photo page', is there a way for me to find out which photos have comments on them without having to go into the photo page for each and every image and click the 'View Info' icon there?
I do like the way in other themes that you can see at the album level an indication of commenting at the photo level.
I have a feeling I'm stretching Hybrid beyond what it's really meant for...
Thanks for any thoughts.
Posts: 8601
i'm pretty sure the current version of hybrid will show "Comments: 2" next to the thumbnail for a photo with 2 comments, in the album view.
Posts: 168
I'm presuming by 'current' you mean the one available in Gallery ver 2.1? In that case I'm definitely going to dive in and learn how to use CVS to get the latest nightly snapshot. OK, thanks.
Posts: 8601
2.1 is not released yet.. current CVS/nightly snapshots are nearing 2.1. but yes, that one.