[SOLVED] Template/Layout/Theme Question.

ben-wan

Joined: 2005-06-03
Posts: 33
Posted: Sun, 2005-06-05 14:39

Template/Layout/Theme Question.

This is how I access my Gallery...
http://localhost/gallery2/main.php

inside "gallery2/templates" I have created a "local" folder.
and make changes to... global.tpl & sidebar.tpl

Question 1
When I goto "Site Admin --> Layouts and Themes" to change the "layout" or "themes".
Nothing seems to be taken effect. How can I fix the problem?

Question 2
Is it possible to set it up so that, only user "admin" will see the changes I made in global.tpl & sidebar.tpl
and the rest will act like nothing has change?
So, if I want to create another user, it can have it's own look and feel!

Sincerely,
Ben

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-06-05 15:51

i assume you copied global.tpl and sidebar.tpl to the local/ folder.
do the customizations there and then, perhaps you need to click on site admin -> maintenance : flush template cache to see the changes take effect.

if you want different templates based on admin / others, you need to add if (is it the admin user) (pseudocode, you can't use this code) conditions in your templates (smarty code).

take a look at the customization guide for more questions.

moving the topic to the customizations forum.

 
ben-wan

Joined: 2005-06-03
Posts: 33
Posted: Mon, 2005-06-06 07:18

2 more question.. :P

Question 1
I have only copied global.tpl and sidebar.tpl to "gallery2/local" is it correct?
I have try to copy global.tpl and sidebar.tpl to "gallery2/local/e-photo-city"
but some how it doesn't work, If this is the correct method, is there anyway to get it working?

Question 2
um... I don't quite understand the "smarty code" you are talking about...
but I have tried doing this.. and it doesn't work..
in "gallery2/templetes/sidebar.tpl"
Line 1: {if $user.userName == "admin"}
Last Line: {/if}

I guess I have put this "if" statement in a wrong place, is this statement correct? where can I put this code?

Thank you very much!

Sincerely,
Ben

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-06-06 07:24

not gallery2/local, it must be a subdir in the templates dir, so gallery2/templates/local/ is the right dir for global.tpl and sidebar.tpl.

no, you don't have to copy global.tpl / sidebar.tpl to gallery2/layouts/ephotocity/templates/local/
and don't use dashs in your layout name!

after changes, always hit site admin -> maintenance flush templates.

the if statement looks about right.

 
ben-wan

Joined: 2005-06-03
Posts: 33
Posted: Mon, 2005-06-06 09:20

The if statement is ok, but where can I put it?

I have try putting it in... "gallery2/templates/local/global.tpl"
Line 1: {if $user.userName == "admin"}
Last Line: {/if}

but when it is not login, the page is complete white (nothing is being printed)

If I put the line in.. "gallery2/templates/global.tpl"
nothing seems to be happening.. (provide that "gallery2/templates/local/global.tpl" exist.)

What can I do? Thanks so much for helping me...

Sincerely,
Ben

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-06-06 09:33
Quote:
I have try putting it in... "gallery2/templates/local/global.tpl"
Line 1: {if $user.userName == "admin"}
Last Line: {/if}

but when it is not login, the page is complete white (nothing is being printed)

that's exactly what you told G2 to do.
if you do the if condition around the whole global.tpl, then nothing gets rendered if the conditions is evaluated to false, which is the case for users that have not the name "admin".

you can put the if statement in any templates/local/*.tpl file, and between the if and the /if, you can put only 1 line or complete blocks as you did in global.tpl.

there are many .tpl files in G2, don't know which one you want to change.

and as i said, if you change something in a .tpl, go to site admin -> maintenance : flush templates.

if you want to use templates/*.tpl files, make sure there is not corresponding file in templates/local/*.tpl.

maybe i understood you wrong. i guess you want:
if it's the admin, use templates/local/*.tpl, for everyone else, use templates/*.tpl. right?
for this, you'd have to make small changes in G2.
what i'd do: put the files you would like to customize to templates/local/*.tpl and code something like this:

{if $user.userName == "admin"}
    output for the admin user
    {else}
output for everyone else
{/if}
 
ben-wan

Joined: 2005-06-03
Posts: 33
Posted: Mon, 2005-06-06 10:01

I am getting what you mean now... so if there's any file in "templates/local" that has the same name as "templates", it will over ride it automaticly...
so, here's my question...
Can I still put this the folloing code in... "templete/local/global.tpl"

{if $user.userName == "admin"} 
    output for the admin user 
    {else} 
output for everyone else 
{/if}

If yes, here's another question...
The following code gave me an "Internal Server Error"

{if $user.userName == "admin"} 
    output everyting in this file
    {else} 
{include file="gallery:templates/global.tpl"}  <--- this line seems to be giving me problem
{/if}

Is this the "proper" way to do it?
can you please give me some comment as to how this problem can be fix and what is usually the better way to do it?

Thanks..

Sincerely,
Ben

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-06-06 10:52

1. a better condition is {if $user.isAdmin} because the admin can have a different name than "admin".

2. i don't know why but you can't include the global.tpl. better do this if {} {else} {/if} around all your admin specific changes .

 
ben-wan

Joined: 2005-06-03
Posts: 33
Posted: Mon, 2005-06-06 15:07

I finally got it.. :D Thanks... :D