Modifying template [ need to skip items view and go straight to first image ]

draco2002

Joined: 2003-04-28
Posts: 70
Posted: Thu, 2005-10-20 16:53

Not sure what the best way to do this would be.

I want to show the list of albums like normal, but when you click on the album it brings you to the photo view of the first image.

Any help would be greatly appreciated

-Dan

edit: the post you link to is 100% on track, you just need to edit the album.tpl

Thanks for the help!

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2005-10-22 03:15

You're not the only person :) http://gallery.menalto.com/node/38786

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2005-10-22 17:02

draco2002, if you were able to do this, do you mind posting your solution to this thread (I think your title explains itself a little better)? Then I, you or someone can link the Codex to it or you could just create a HowTo on the Codex :)

Thanks.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
draco2002

Joined: 2003-04-28
Posts: 70
Posted: Sat, 2005-10-22 18:53

making me give away all my secrets now ;)

my mod is based off of the sirux theme

add this in theme.inc after line 97:

Quote:
foreach ($childIds as $childId){
$childEntity = GalleryCoreApi::loadEntitiesById($childId);
$childItemIds = GalleryCoreApi::fetchChildItemIds($childEntity[1]);
$theme['firstImage'][$childId] = $childItemIds[1][0];
}

modify line 30 of album.tpl to look like this:

Quote:
<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.firstImage[$child.id]`"}">

Hope this helps out.

-Dan

|| G1 + G2 Hosting | Custom Theming | Donate to Gallery ||

 
Washi

Joined: 2005-11-19
Posts: 5
Posted: Sun, 2005-11-20 03:09

I tried that Draco2002. Didn't work for me.

I'm using Siriux for "main" gallery, and PG Theme for the albums, and, I'm kinda confused, cause I have no idea which theme to try to mod. And, I tried modding the PG one, but got an error:

Parse error: parse error, unexpected T_FOREACH, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/user/public_html/rach/gallery2/themes/PGtheme/theme.inc on line 604

I'm about to tear my hair out. Help please?

 
draco2002

Joined: 2003-04-28
Posts: 70
Posted: Sun, 2005-11-20 04:49

That code is for the siriux them. I haven't played much with the PG Theme, but attach your theme.inc file (rename it theme.txt) and i'll take a look and see what i can dig up for you

-Draco

|| G1 + G2 Hosting | Custom Theming | Donate to Gallery ||

 
Washi

Joined: 2005-11-19
Posts: 5
Posted: Mon, 2005-11-21 15:30

Thanks a lot. Like I said, before we start anything, my "main" gallery page is done in siriux, I want to be able to click the album name and go directly to the first picture in the album, in the PG theme.
I'm attaching the theme.inc renamed to theme.txt for the PG Theme. Thanks a lot for your help. :D

 
Washi

Joined: 2005-11-19
Posts: 5
Posted: Sun, 2005-11-27 23:37

Anyone? It's been almost a week, and I'd kinda need to get the gallery up and running soonish. Thank you.

 
TuBaG

Joined: 2004-09-01
Posts: 5
Posted: Fri, 2005-12-02 21:36

I'm struggling to pull this template modification off also. Any success?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2005-12-03 16:45

draco2002, When trying to apply this change to the Siriux theme with a current CVS I get this error
Fatal error: Call to undefined function: getorderby() in /path/to/g2install/modules/core/classes/helpers/GalleryChildEntityHelper_simple.class on line 245
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
Washi

Joined: 2005-11-19
Posts: 5
Posted: Mon, 2005-12-05 13:43

Ok, I have a question. When you use this kind of way of seeing the gallery, how can you edit the album? Since there isn't an actual thumbnails page, how can you make a link somewhere to edit the whole album and not just the photo?

 
RickiusMaximus

Joined: 2005-12-06
Posts: 9
Posted: Tue, 2005-12-06 11:26

Hiall,

I am also attempting to do this using the matrix template and the posted method is not working for me.

From what I can see the program checks to see if the item has children, and if it does it contines to show the album page until it reaches an item which has no children, upon which it shows the photos page.

Can anyone help?

 
RickiusMaximus

Joined: 2005-12-06
Posts: 9
Posted: Wed, 2005-12-07 09:16

Okaydoke, this works but the lines you have to enter the information are different.

For the Matrix theme-

1. open theme.inc

2. go to line 84 and insert-

Quote:
foreach ($childIds as $childId){
$childEntity = GalleryCoreApi::loadEntitiesById($childId);
$childItemIds = GalleryCoreApi::fetchChildItemIds($childEntity[1]);
$theme['firstImage'][$childId] = $childItemIds[1][0];
}

(Thats inside the

Quote:
@see GalleryTheme::showAlbumPage

section just before)

Quote:
return array(GalleryStatus::success(), 'theme.tpl');

3. open album.tpl

4. go to line 62 and change-

Quote:
<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">

to

Quote:
<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.firstImage[$child.id]`"}">

There is still one issue however, the navigator button at the top (gallery >> album >> photo.jpg) is still clickable and brings up this error message-

Quote:
Fatal error: Call to undefined function: getorderby() in gallery\modules\core\classes\helpers\GalleryChildEntityHelper_simple.class on line 512

Any ideas for this? Or is disabling the link an easier option?

 
RickiusMaximus

Joined: 2005-12-06
Posts: 9
Posted: Fri, 2005-12-09 15:21

This error message also comes up if you attempt to add an image to the mainpage rather than in a subalbum (thus effectivly crippling your page)

Can anyone help me with this?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2005-12-12 01:11

Ah, so some additional logic may need to be added so it handles this gracefully. I be you'd have the same problem on other albums that contain sub-albums, maybe not though as I haven't tested this. Ouch, well I burned my hande tonight and can barely type. I'm done for the night.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
RickiusMaximus

Joined: 2005-12-06
Posts: 9
Posted: Tue, 2005-12-13 16:45

Ive re-written a big chunk of the matrix album code inorder to differentiate between images and albums better-

Quote:
{* Check if album with images*}

{if $child.canContainChildren && isset($child.thumbnail)}

{assign var=frameType value="albumFrame"}
<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.firstImage[$child.id]`"}">
{g->image item=$child image=$child.thumbnail class="giThumbnail"}

{* Check if album without images*}

{elseif $child.canContainChildren}

{assign var=frameType value="albumFrame"}
<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.firstImage[$child.id]`"}"
class="giMissingThumbnail">
{g->text text="Click here to add Photos!"}

{* Else photo *}

{else}

{assign var=frameType value="itemFrame"}
<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">
{g->image item=$child image=$child.thumbnail class="giThumbnail"}

{/if}

But still no joy, the error appears as soon as tou add an image so the problem is somewhere in the theme.inc file, unfortunatly I'm way outta my depth when I get in there :(

Can anyone give me a hint as to what might be causeing this?

 
bayon86

Joined: 2008-12-02
Posts: 17
Posted: Tue, 2008-12-16 14:01

I tried to use draco's code but it didn't work for me. The call to GalleryCoreApi::fetchChildItemIds($childEntity[1]); would give me errors when i was on subalbum pages. I spent quite a few hours puzzling this out, so I thought I would pass along the code, just in case anybody else wants to do this. I am using ebony theme, but i think this should will work with most themes.

in gallery>themes>your-theme>theme.inc insert this code into function showAlbumPage

Quote:
$firstImages = array();
foreach ($childIds as $childId){
$childEntity = GalleryCoreApi::loadEntitiesById($childId);
if ($childEntity[1]->canContainChildren) {
$childItemIds = GalleryCoreApi::fetchChildItemIds($childEntity[1]);
$firstImages[] = $childItemIds[1][0];
}
}

then in your album.tpl page on this line:

Quote:
{foreach from=$theme.children item=child}

change to

Quote:
{foreach from=$theme.children item=child key=k}

the key=k will give you a number for the iteration of the foreach loop

down further, depending on your theme, you will need to incorporate this code with the code that creates the links

Quote:
{* if canContainChildren, it must be an album, so let's use the album's first photo id for the link *}

{if ($child.canContainChildren) }

<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.firstImages[$k]`"}">{g->image id="%ID%" item=$child image=$child.thumbnail class="%CLASS% giThumbnail "}</a>

{elseif isset($child.thumbnail)}

{* otherwise just use the thumbnail id *}

<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">{g->image item=$child image=$child.thumbnail class="giThumbnail "}</a>

{else}

<a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}" class="giMissingThumbnail"> {g->text text="no thumbnail"}</a>

{/if}

hth.

 
fmmcmillan

Joined: 2009-06-16
Posts: 18
Posted: Sun, 2010-12-05 10:10

Has anyone done this successfully for the Carbon theme?