In the new theme I'm trying to make, I'd like to be able to set class="giNew" (or something similar) on thumbnails for new items in Album View (simiarly for updated items) so I can use CSS to highlight these photos. However, I can't figure out an easy way to do this, as I'd like it to be integrated in with the "newitems" module (or at least use the 'days old' settings from there). I think I could do it by basically copying out the PHP funtion that runs the newitems module and pasting it into my theme, but that's pretty clunky.
I guess what I'd like to see is for each item object to have a variable called status (or something) if the 'newitems' module is activated, and this would be either blank (nothing special about the item), 'new' or 'updated'. This would then allow me to quickly and easily test which items are new/updated and change my theme accordingly. Right now it seems that the only output from the newitems module is the line in the itemSummaries, and it's not really useful for anything beyond displaying in itemSummaries.
I could just hack the newitems module but I'd rather not use any more non-standard code than I have to (so I don't worry while updating) and I don't know if I understand enough now to hack the module as I want anyway.
So any help would be appreciated!
Posts: 32509
hmm, good idea. you can add this in a modular way, but not without changing the album.tpl file and perhaps not without chaning the newitems module or creating your own newitems module.
let's see...
yes i guess you'd have to extend the newitems module.
in themes/matrix/templates/album.tpl, you'd have to add a check and your css stuff around the thumbnail and in the modified newitems module, you could hack something together.
the goal is to assign template variables with the "is this item new" information.
this is not the clean way, but with the current g2 architecture, i don't know how this should be done the clean way (unless you do it in the theme.inc file.
ok, let's do it the clean way.
if you haven't already, create your own theme (start by cloning your prefered theme), see the theme docs on codex.gallery2.org on how to do that.
open the theme.inc file of your theme,
in function showAlbumPage
before
add:
and then in album.tpl, you'll have to add
or something like that.
Posts: 39
Thanks Valiant, you were really close. PHP threw a couple errors in your code (one missing parenthesis) but it didn't like the &$item in the foreach loop, said "Parse error: parse error, expecting `T_VARIABLE' or `'$'' in theme.inc". I hacked around a bit and managed to make it work with the following code:
It's not quite as 'pretty' as your code, but at least it works. Have you run into this problem with &$whatever in a foreach loop before? Anyway, it works, so that's all I care about. Thanks!
Posts: 32509
good that it works. i wasn't sure anymore if the as &$var works in foreach. good that you know php and could fix it yourself