1
gstarrett
"Best" place to put custom theme functions?
  • 2003/7/19 7:28

  • gstarrett

  • Friend of XOOPS

  • Posts: 174

  • Since: 2002/3/12


Where is the recommended place to put theme-related functions in a XOOPS theme? Is there a themedir/function.php that would be included to handle defines of theme-specific functions?

Specifically, I am converting my current site into a XOOPS2 smarty theme. I'm making good progress, but I have the theater's time in the headerbar area (just below where the banner typically goes if you look at the link). I'm not sure where to put that.

Also, there are likely some other things that, if I do a straight transition, would need custom functions like the user agent info and the navigation section (top left--it's extremely basic on the site now but with more advanced navigation I could see more levels of path appearing).

Thoughts? I'm hoping I don't need to hack XOOPS core because I'm trying to keep my hacks seperate from my theme.

Thanks!

2
gstarrett
Re: "Best" place to put custom theme functions?
  • 2003/7/20 18:29

  • gstarrett

  • Friend of XOOPS

  • Posts: 174

  • Since: 2002/3/12


Anyone have any ideas? I'm hoping someone can provide some guidance, or perhaps tell me I'm heading down a track that "isn't done because...".

Anyone?

Thanks!

3
ackbarr
Re: "Best" place to put custom theme functions?

since an XOOPS theme is really nothing more than a template displaying variables supplied by the XOOPS core and modules, I think your only option is a core hack. However you can isolate these functions into a seperate file and include the file into /common.php, thus minimizing the core modifications necessary and simplifying their removal if needed.

You will also need to assign the function returns to smarty variables for your theme to utilize them. For examples of how to assign variables to the smarty engine, take a look at the module kickstart guide.

4
chapi
Re: "Best" place to put custom theme functions?
  • 2003/7/20 21:30

  • chapi

  • Theme Designer

  • Posts: 611

  • Since: 2002/1/22


As XOOPS uses smarty you should also be able to include some php files with it. Look at the following site for more information on this topic ...

http://smarty.php.net/manual/en/language.function.include.php.php

5
gstarrett
Re: "Best" place to put custom theme functions?
  • 2003/7/20 21:41

  • gstarrett

  • Friend of XOOPS

  • Posts: 174

  • Since: 2002/3/12


Thanks!! That's exactly what I was hoping to find.



6
gstarrett
Re: "Best" place to put custom theme functions?
  • 2003/7/20 23:45

  • gstarrett

  • Friend of XOOPS

  • Posts: 174

  • Since: 2002/3/12


Quote:
chapi wrote:
As XOOPS uses smarty you should also be able to include some php files with it. Look at the following site for more information on this topic ...

http://smarty.php.net/manual/en/language.function.include.php.php


Follow-up:

The include_php function requires an absolute path to the PHP file. That's a bit cumbersome when you're dealing with win32 dev and RH8 prod. I couldn't seem to find any way to get the template's directory pre-pended to the include file (XOOPS vars unavailable, smarty vars not set??)

However, the {php} directive does work as advertised and allows me to accomplish what I wanted. The downside is I need to include the PHP code in my template--less than ideal.

I suppose it's possible the XOOPS vars are available within the smarty PHP block but I didn't check that.

Here's how I included the PHP code in my template, in case anyone wants to try it with theirs.

...
<{
php}>
// Include theme-specific functions
function dt_AZtime() {
    
# Calculate current AZ time -- Server is not in MST time zone
    # offset to server = -7h - (server offset)
    
$MST_to_Server_offset = -60 60 date"Z" );
    return 
time() + $MST_to_Server_offset;
}
    
    
$this->assign('theme_localtime'date"g:ia,  F j, Y"dt_AZtime()));
<{/
php}>

  <
table cellspacing="0">
...
      <
td id="headerbar"><a href="<{$xoops_url}>/">GAPT</a>: <{$xoops_pagetitle}></td>
      <
td id="headerbar-right"><{$theme_localtime}></td>
...


P.S. Many thanks to Chapi to pointing me to the Smarty site and getting me headed in the right direction.

7
wammes
Re: "Best" place to put custom theme functions?
  • 2003/11/20 13:02

  • wammes

  • Not too shy to talk

  • Posts: 101

  • Since: 2002/1/3 1


This thread made me thinking about my own theme.

I have created a theme that used custum (extra) smartyvariables. Currently I've hacked the core to get my extra variables. Putting all those hacks in a seperate php file, would be a much nices solution. Currently I've hacked header.php to get extra user info and the news module (article.php) to separate the article title from the article category.

Now my question:
If I include a php file in theme.html, is it possible to get the extra userinfo that I want (userrank, number of unread pm) and the extra news variables (article title and article category) in a smarty variable to call in theme.html?
I see problems with getting the userinfo in that php file. How will I know in that file what the current user and current news article is? I probably have to make inclusions and globals in that php file...??
I know I want a lot for a php newbie .

Login

Who's Online

48 user(s) are online (32 user(s) are browsing Support Forums)


Members: 0


Guests: 48


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Aug 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits