Best way to get gallery path or theme path

shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Tue, 2005-08-16 01:56

So i'm trying to do a php include in a template. Right now i'm having to do the include from the url because I can use g->url to get the url of my theme folder. Is there a way I can get the path of my theme folder while inside a template? Thanks.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2005-08-16 02:13

Here's an example out of theme.tpl{g->theme include="album.tpl"}

Are you looking for something different?

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Tue, 2005-08-16 10:16

does that work the same if i'm just including a php file full of functions. I guess i thought that was only for tpl files.

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Tue, 2005-08-16 13:54

I don't know. I thought you were trying to include a template. You can always try and if it works it works ;)

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-08-16 15:13

{php}include(dirname(__FILE__) . '/file');{/php}

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-08-16 15:17

actually, dirname(__FILE__) will probably be the compiled smarty dir, under g2data/smarty, so it won't be the right path. i don't think we chdir anywhere, so 'themes/name/templates/file' might work, ie relative path from gallery2 dir.

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Tue, 2005-08-16 15:28

yep, tried dirname(__FILE__) already and came to the same conclusion you did. I have no problem doing the relative path from the gallery2 directory. How do I get that path from inside a template? Thanks.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-08-16 19:07

don't you know the location of the file you want to include? just put the relative path.

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Tue, 2005-08-16 19:29

i see what your saying now, i'm retarded. thanks.

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Wed, 2005-08-17 13:03

Wait I don't see what you are saying. How do I get the relative path from the smarty cache folder inside the g2data folder to gallery itself. Or how do I get the full path of gallery. Thanks.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2005-08-17 14:06

pwd while this request is running should be the gallery2 dir.

here's another option:
{php}GalleryCoreApi::relativeRequireOnce('themes/.../.../file');{/php}

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Wed, 2005-08-17 15:30

ok, thanks. I'll give that a go.

 
shocksll
shocksll's picture

Joined: 2005-06-22
Posts: 352
Posted: Thu, 2005-08-18 10:57

That worked great. Thanks again.