matrix -> center incomplete rows

LarryDoliver

Joined: 2003-12-31
Posts: 35
Posted: Thu, 2005-08-04 04:42

A made a small change to matrix to center the thumbnails on rows that are not full, like these: (see the last row)
http://tautologous.com/gallery2/travel/Oaxaca/
http://tautologous.com/gallery2/travel/Oaxaca/Santo_Domingo/
edit 2005-09-10: nivekiam fixed broken links, removed /v

Here's the patch:
edit 2005-09-24: nivekiam converted HTML char codes to characters to make copy and paste easier

@@ -58,14 +58,14 @@

         {assign var="childrenInColumnCount" value=0}
         <div class="gbBlock">
-          <table id="gsThumbMatrix" width="100%">
-            <tr valign="top">
+          <table id="gsThumbMatrix" width="100%" >
+            <tr valign="top"><td align=center ><table width="100%"><tr>
               {foreach from=$theme.children item=child}

               {* Move to a new row *}
               {if ($childrenInColumnCount == $theme.params.columns)}
-            </tr>
-            <tr valign="top">
+            </tr></table></td></tr>
+            <tr valign="top"><td align=center ><table width="100%"><tr>
               {assign var="childrenInColumnCount" value=0}
               {/if}

@@ -134,9 +134,8 @@

               {* flush the rest of the row with empty cells *}
               {section name="flush" start=$childrenInColumnCount loop=$theme.params.columns}
-              <td>&</td>
               {/section}
-            </tr>
+            </tr></table></td></tr>
           </table>
         </div>
         {/if}

edit 2005-09-24: nivekiam left this just incase I screwed up some of the HTML code conversion

@@ -58,14 +58,14 @@

         {assign var="childrenInColumnCount" value=0}
         <div class="gbBlock">
-          <table id="gsThumbMatrix" width="100%">
-            <tr valign="top">
+          <table id="gsThumbMatrix" width="100%" >
+            <tr valign="top"><td align=center ><table width="100%"><tr>
               {foreach from=$theme.children item=child}

               {* Move to a new row *}
               {if ($childrenInColumnCount == $theme.params.columns)}
-            </tr>
-            <tr valign="top">
+            </tr></table></td></tr>
+            <tr valign="top"><td align=center ><table width="100%"><tr>
               {assign var="childrenInColumnCount" value=0}
               {/if}

@@ -134,9 +134,8 @@

               {* flush the rest of the row with empty cells *}
               {section name="flush" start=$childrenInColumnCount loop=$theme.params.columns}
-              <td>&</td>
               {/section}
-            </tr>
+            </tr></table></td></tr>
           </table>
         </div>
         {/if}
 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Thu, 2005-08-04 04:58

I like that, that's pretty cool. That's for sharing.

I assume it's album.tpl that you're editing for this, correct?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-08-04 10:16

LarryDoliver, great work. also presenting panoramas like you do in http://tautologous.com/gallery2/v/panoramas/ looks great.

if it isn't yet in the demos sticky topic, please add it there!

 
LarryDoliver

Joined: 2003-12-31
Posts: 35
Posted: Thu, 2005-08-04 22:05
valiant wrote:
LarryDoliver, great work. also presenting panoramas like you do in http://tautologous.com/gallery2/v/panoramas/ looks great.

if it isn't yet in the demos sticky topic, please add it there!

Thanks - will do...

 
Semichrist

Joined: 2005-08-01
Posts: 4
Posted: Mon, 2005-08-08 02:22

Thanks! I have implemented this on my site. One suggestion though. If you do not add valign="top" to the new tr tags you added, the rows of thumbnails can get a bit ragged if some have titles and others do not...

 
pippin88

Joined: 2005-09-17
Posts: 23
Posted: Mon, 2005-09-26 00:46

I tried to fix up the code (get rid of all those stuffed characters):

{* @@ -58,14 +58,14 @@ *}

         {assign var="childrenInColumnCount" value=0}
         <div class="gbBlock">
           <table id="gsThumbMatrix" width="100%">
             <tr valign="top">
           <table id="gsThumbMatrix" width="100%" >
             <tr valign="top"><td align=center> <table width="100%"><tr>
               {foreach from=$theme.children item=child}

               {* Move to a new row *}
               {if ($childrenInColumnCount == $theme.params.columns)}
             </tr>
             <tr valign="top">
             </tr></table></td></tr>
             <tr valign="top"><td align=center ><table width="100%"><tr>
               {assign var="childrenInColumnCount" value=0}
               {/if}

        {* @@ -134,9 +134,8 @@ *}

               {* flush the rest of the row with empty cells *}
               {section name="flush" start=$childrenInColumnCount loop=$theme.params.columns}
              <td></td>
               {/section}
             </tr>
             </tr></table></td></tr>
           </table>
         </div>
         {/if}

However, I can't get it working.
In that form it expects the last {/if} to be a {/foreach}. If I do that it expects the foreach further down in albums.tpl to be a {/if} (this is all for matrix btw).
If I comment out the final {/if} in this code, it doesn't give me an error, just borks the gallery view. The first picture occupies the same row as the album title and date row, and the rest appear in a line below the side bar.

A little help would be great.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2005-09-26 07:18

Pippin88, I fixed the code above. The lines that start with a (-) are lines you need to remove, then lines that start with a (+) are lines you need to add. It's a patch so it's telling you what you need to change to make the modification. It should work with the current shipping version of G2 as it appears to work on his site though he's not patched the current version of album.tpl in his <theme>/templates/local directory.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live [url=href="http://photos.kevinnehls.com]here[/url]

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Mon, 2005-09-26 11:00
Semichrist wrote:
Thanks! I have implemented this on my site. One suggestion though. If you do not add valign="top" to the new tr tags you added, the rows of thumbnails can get a bit ragged if some have titles and others do not...

Rather fix it in the css. Never use the valign attribute; it is deprecated!!
______________________
I made a theme for G2, try it :)

 
pippin88

Joined: 2005-09-17
Posts: 23
Posted: Mon, 2005-09-26 23:44

I applied this change, but didn't like the effect (it stuffed up the alignment on rows with any portrait oriented shots) but now I can't get rid of it?

Changed back to my old album.tpl that doesn't have it, but it's still doing the effect. Deleted the cache for my theme but its still doing it??

Ideas?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2005-09-27 00:02

First be sure you deleted the file from your /theme/<yourtheme>/templates/local directory. Then clear out the template cache in Site Admin > Maintenance

If you're still seeing it then it's a browser cache issue and you should just need to clear your browser cache.

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live [url="http://photos.kevinnehls.com]here[/url]

 
pippin88

Joined: 2005-09-17
Posts: 23
Posted: Tue, 2005-09-27 01:32

Clearing the cache through site admin fixed it, cheers.

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Tue, 2005-09-27 05:08
pippin88 wrote:
I applied this change, but didn't like the effect (it stuffed up the alignment on rows with any portrait oriented shots) but now I can't get rid of it?

Changed back to my old album.tpl that doesn't have it, but it's still doing the effect. Deleted the cache for my theme but its still doing it??

Ideas?

The reason that happens is because instead of it being one table a new table is created for every row, I was already thinking to look at this code and perhaps make my own version that only creates a new table for the last rows. But I think that is kind of a lot more complicated to do...
______________________
I made a theme for G2, try it :)

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2005-09-27 13:49

RwD, I'm not 100% sure, but I don't think it would be too hard to do. I'm pretty sure you can find out the number of rows that are suppose to be displayed on a page. Then you should just have to increment a variable until it equals that value then create the table. However, I'm not a programmer, I just play one on TV :)
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Tue, 2005-09-27 14:35

Yes, but then it is a better idea to base yourself on the total nr of items for the current page and do (total div columns) + 1 to find out which row needs a separate table and ((total modulo columns) != 0) to find out if you need one at all. As easy as eating pancakes... Then put code for this part into a template (here's the ouch-ier part of the operation)

;)

______________________
I made a theme for G2, try it :)