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.
Here's an example out of theme.tpl{g->theme include="album.tpl"}
Are you looking for something different?
shocksll
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
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
Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-08-16 15:13
{php}include(dirname(__FILE__) . '/file');{/php}
mindless
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
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
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
Joined: 2005-06-22
Posts: 352
Posted: Tue, 2005-08-16 19:29
i see what your saying now, i'm retarded. thanks.
shocksll
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
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}
Posts: 16504
Here's an example out of theme.tpl
{g->theme include="album.tpl"}
Are you looking for something different?
Posts: 352
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.
Posts: 16504
I don't know. I thought you were trying to include a template. You can always try and if it works it works ;)
Posts: 8601
{php}include(dirname(__FILE__) . '/file');{/php}
Posts: 8601
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.
Posts: 352
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.
Posts: 8601
don't you know the location of the file you want to include? just put the relative path.
Posts: 352
i see what your saying now, i'm retarded. thanks.
Posts: 352
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.
Posts: 8601
pwd while this request is running should be the gallery2 dir.
here's another option:
{php}GalleryCoreApi::relativeRequireOnce('themes/.../.../file');{/php}
Posts: 352
ok, thanks. I'll give that a go.
Posts: 352
That worked great. Thanks again.