Welcome to Geeklog, Anonymous Saturday, November 23 2024 @ 10:38 pm EST

Geeklog Forums

How do I use functions.php?


Atealtha

Anonymous
I have some PHP background so this is not a "code for me" post. I just could not find documentation on functions.php (the one that is in each theme folder). Can anyone explain to me or point to the documentation?

I'm looking to make a little random picture script, which shows a random picture from the integrated Gallery system everytime a page loads. Thanks in advance.
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
The functions.php is there for any theme-related PHP code that you may need. You can actually use PHP in the theme's header.thtml, so if you need to write a function, you can put it into the functions.php and call it from header.thtml.

A random picture script would probably be independent of the theme. A better place for such a piece of code would be lib-custom.php (in the systems directory).

bye, Dirk
 Quote

Atealtha

Anonymous
So if my function name is picture() all I need to put in the template file is {picture} ?
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
Err, no, if your function's name is "picture", then of course you call it as picture(). Or, rather,
Text Formatted Code
<?php picture(); ?>
 

bye, Dirk
 Quote

Status: offline

Blaine

Forum User
Moderator
Registered: 07/16/02
Posts: 1232
Location:Canada
Is there a particular template that your looking to use {picture} in?

Any variable in {braces} is parsed by the template class and replaced by the template->set_var method. So just adding {variable} will only work if the code using that template is also setting that variable.

functions.php is often used to control the template that is being used - where you may set the name of the template to be used for a particular block as in
Text Formatted Code

$_BLOCK_TEMPLATE['glMenu']  = 'glmenu/blockheader-menu.thtml,glmenu/blockfooter-menu.thtml';

 

Geeklog components by PortalParts -- www.portalparts.com
 Quote

All times are EST. The time is now 10:38 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content