Album Cell Background Color

doomdead

Joined: 2003-04-06
Posts: 174
Posted: Mon, 2005-09-19 04:43

Hi all. Running G2 final on IIS6. Everythings great. I'm using the Matrix theme, and would like to change the grey album cell background color on the MAIN page only /gallery2/, i want it all to be white. But I want the rest of gallery to fall under the standard theme, grey cell background for albums, rest of the background white, etc.

Sure would be nice to be able to edit the css in the theme (global) and on individual albums. this would allow me to achieve the above.

Or am I missing on how to do it?

thanks :)

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Mon, 2005-09-19 12:56

I do not know of a way that comes standard with gallery, but I have not looked into it very deeply. However, I do know of a way how to do it:

  • Go to the directory "gallery2/themes/matrix/templates/local" (create if it isn't there)
  • Create a new file called "album.tpl" with the following content:
{*
 * $Revision: 1.10 $
 * If you want to customize this file, do not edit it directly since future upgrades
 * may overwrite it.  Instead, copy it into a new directory called "local" and edit that
 * version.  Gallery will look for that file first and use it if it exists.
 *}
<table width="100%" cellspacing="0" cellpadding="0">
  <tr valign="top">
    {if !empty($theme.params.sidebarBlocks)}
    <td id="gsSidebarCol">
      {g->theme include="sidebar.tpl"}
    </td>
    {/if}
    <td>
      <div id="gsContent" class="gcBorder1">
        <div class="gbBlock gcBackground1">
          <table style="width: 100%">
            <tr>
              <td>
                {if !empty($theme.item.title)}
                <h2> {$theme.item.title|markup} </h2>
                {/if}
                {if !empty($theme.item.description)}
                <p class="giDescription">
                  {$theme.item.description|markup}
                </p>
                {/if}
              </td>
              <td style="width: 30%">
                {g->block type="core.ItemInfo"
                          item=$theme.item
                          showDate=true
                          showSize=true
                          showOwner=true
                          class="giInfo"}
              </td>
            </tr>
          </table>
        </div>

        {if !empty($theme.navigator)}
        <div class="gbBlock gcBackground2 gbNavigator">
          {g->block type="core.Navigator" navigator=$theme.navigator reverseOrder=true}
        </div>
        {/if}

        {if !count($theme.children)}
        <div class="gbBlock giDescription gbEmptyAlbum">
          <h3 class="emptyAlbum">
	    {g->text text="This album is empty."}
	    {if isset($theme.permissions.core_addDataItem)}
	    <br/>
              <a href="{g->url arg1="view=core.ItemAdmin" arg2="subView=core.ItemAdd" arg3="itemId=`$theme.item.id`"}"> {g->text text="Add a photo!"} </a>
	    {/if}
          </h3>
        </div>
        {else}

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

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

              {assign var=childrenInColumnCount value="`$childrenInColumnCount+1`"}
              <td class="{if $child.canContainChildren}giAlbumCell{$theme.item.id} giAlbumCell gcBackground1{else}giItemCell{/if}"
                  style="width: {$theme.columnWidthPct}%">
                {if $child.canContainChildren}
                {assign var=frameType value="albumFrame"}
                {else}
                {assign var=frameType value="itemFrame"}
                {/if}
                <div>
                  {if isset($theme.params.$frameType) && isset($child.thumbnail)}
		    {g->container type="imageframe.ImageFrame" frame=$theme.params.$frameType}
		      <a href="{g->url arg1="view=core.ShowItem" arg2="itemId=`$child.id`"}">
			{g->image id="%ID%" item=$child image=$child.thumbnail
			 class="%CLASS% giThumbnail"}
		      </a>
		    {/g->container}
                  {elseif isset($child.thumbnail)}
		    <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}
                </div>

                {g->block type="core.ItemLinks" item=$child links=$child.itemLinks}

                {if !empty($child.title)}
                <p class="giTitle">
                  {if $child.canContainChildren}
                  {g->text text="Album: %s" arg1=$child.title|markup}
                  {else}
                  {$child.title|markup}
                  {/if}
                </p>
                {/if}

                {if !empty($child.summary)}
                <p class="giDescription">
                  {$child.summary|markup|entitytruncate:256}
                </p>
                {/if}

                {if ($theme.item.canContainChildren && $theme.params.showAlbumOwner) ||
                    (!$theme.item.canContainChildren && $theme.params.showImageOwner)}
                {assign var="showOwner" value=true}
                {else}
                {assign var="showOwner" value=false}
                {/if}
                {g->block type="core.ItemInfo"
                          item=$child
                          showDate=true
			  showOwner=$showOwner
                          showSize=true
       		          showViewCount=true
                          showSummaries=true
                          class="giInfo"}
              </td>
              {/foreach}

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

        {if !empty($theme.navigator)}
        <div class="gbBlock gcBackground2 gbNavigator">
          {g->block type="core.Navigator" navigator=$theme.navigator reverseOrder=true}
        </div>
        {/if}

        {if !empty($theme.jumpRange)}
        <div id="gsPages" class="gbBlock gcBackground1">
          {g->block type="core.Pager"}
        </div>
        {/if}

        {g->block type="core.GuestPreview" class="gbBlock"}

        {* Our emergency edit link, if the user all blocks containing edit links *}
	{g->block type="core.EmergencyEditItemLink" class="gbBlock"
                  checkSidebarBlocks=true
                  checkAlbumBlocks=true}

        {* Show any other album blocks (comments, etc) *}
        {foreach from=$theme.params.albumBlocks item=block}
          {g->block type=$block.0 params=$block.1}
        {/foreach}
      </div>
    </td>
  </tr>
</table>
  • Find out what the start id for your gallery is. (for example click on the link in the breadcrumb when you are in a subalbum, the number that is behind "g2_itemId=" in the URL is the id you need) (This method only works with url_rewrite disabled; in the case of IIS6 url_rewrite will not be enabled)
  • Suppose the id is 7: Inside the matrix stylesheet add #gsContent #gsThumbMatrix .giAlbumCell7{background-color:red;}

That should do it. I haven't tested this method, but in theory it is working...

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Mon, 2005-09-19 13:02

ps, can anybody tell me if the css file can also be altered in a way that will not destroy your changes when uploading a new version of gallery (by simply overwriting the old file :().

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2005-09-19 13:41

Yes, you can create a 'local' directory in /themes/<yourtheme>/ and place the css file in there. If you reference images in your css file (like the next, last, previous, first, login images, etc) you can either copy the theme's images directory into that file, change the references in the css file to ../images or create a symlink in that 'local' directory of images -> ../images

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Mon, 2005-09-19 13:47

Ow ok, this was one of my wrong assumptions then yet again where I thought the trick probably wouldn't work for css files because their path is included in the html file instead of them being included by the php script.

Something in de back of my mind did tell me I could do that :P

--------

In this case the css should be copied into a directory called local, and change that.

 
doomdead

Joined: 2003-04-06
Posts: 174
Posted: Mon, 2005-09-19 16:03

Thanks RwD I'll give it a try and let you know.

 
doomdead

Joined: 2003-04-06
Posts: 174
Posted: Mon, 2005-09-19 16:17

Exactly what i wanted. Thanks.

I chose white witht the default template because im using spiral notebook frames on just my front page. and they're white. this looks great. Thank you.

Maybe someone can post this as a feature request? Be able to manipulate the CSS per album..

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Mon, 2005-09-19 16:54

Hmmz, I am not sure how you envision per album cs manipulation, several ways can be thought of. But they are all very much dependant on the contents like my solution is. It might work on one, but not the other...

Perhaps there is a way to indeed do that, but I think the next best thing would to be able to have first page specific settings. That would be very nice. I would for example want a random image block on the root gallery, but not in the others. Right now I have to program it because right now I don't want to use the solution I gave you of having the template sort it out. (I want a programmatical solution that will work for everyone). I will post something here if it ain't too overly complex to easily explain...

edit
Actually I just thought perhaps it would be possible to define a style sheet that is stored in the database and included when an album loads. This stylesheet simply includes the normal stylesheet or the normal stylesheet is loaded before the custom one in a different fashion; and it is done. Doesn't sound too hard...

Perhaps you should make it a feature request; I would vote for it :P

 
doomdead

Joined: 2003-04-06
Posts: 174
Posted: Tue, 2005-09-20 01:22

I might have already, i made a couple.

RwD, since you were right on the ball with this, let me see if you can take it one more step. I had around 3 other gallery 1 installs on my server, I just did a big upgrade today to g2 for them all using the multisite installation. As I converted mine over to the multisite codebase, I (of course) lost this customization I just had. I could easily reapply it to the codebase, but then every install would have this effect.

Is there a way around this to just apply it to mine?

Edit:
I found 'giAlbumCell{$theme.item.id}' in the tpl file. If I can just add another identifier that is unique to MY gallery, I can modify the stylesheet the same way and do it. Ironically my theme.item.id is 6 and everyone elses so far is 7, so its not effecting anything. But i'd really appreciate a tip on what I can use thats unique to me.

thanks

 
RwD
RwD's picture

Joined: 2005-01-09
Posts: 383
Posted: Tue, 2005-09-20 07:20

Since you have the problem that the change is visible for every gallery on the multisite installation I think there is not a lot you can change easily inside the theme itself and it will have to become a setting you make for your gallery in the database:

You could for example simply copy the matrix theme folder and call it "matrix reloaded" or "matrixtoo" :P
If you change the inc file in the "matrixtoo" folder and change every mention of the word matrix into matrixtoo, you can use the second matrix theme next to the other and only have your gallery use the matrixtoo style. Do remember to undo the changes for the standard matrix style.

Here is an example of what a changed theme'c inc file (The theme is called Example) looks like at the start:

class ExampleTheme extends GalleryTheme {

    /**
     * Constructor
     */
    function ExampleTheme() {
	global $gallery;

	$this->setId('example');
	$this->setName($gallery->i18n('Example'));
	$this->setDescription($gallery->i18n('Example gallery'));

(I am not that much into multi languag, but I think the '$gallery->i18n' names are also identifiers for multilanguages if you set those up...)

(I am also not sure if this is the best way to do it, but it works...)