1
gabrielk
Using PHP within a Theme File
  • 2006/2/28 17:46

  • gabrielk

  • Just popping in

  • Posts: 2

  • Since: 2006/2/28


Hi,

I'm new to working with Xoops. I inserted some PHP code into my /themes/mytheme/theme.html file, however when I view the page, the PHP is printed in the source code and not actually executed. Any help as to what's going on, and how to get the PHP code to actually execute would be much appreciated, I'm stumped! :)

2
Lance_
Re: Using PHP within a Theme File
  • 2006/2/28 18:05

  • Lance_

  • Home away from home

  • Posts: 983

  • Since: 2004/1/12


Could you show the snippet of you theme.html with the code.

It should work, since the theme.html already has php in it. I wonder if it's not a tag problem. Code not within the <?php...?> tags.
GDL-Web.com :: Website development.
Xoopslance.com::Freelancing and Projects
thelionsden-arena.net:: Clan/League/Ladder Hosting

3
gabrielk
Re: Using PHP within a Theme File
  • 2006/2/28 22:39

  • gabrielk

  • Just popping in

  • Posts: 2

  • Since: 2006/2/28


Here's a sample of the code below. I've double checked the syntax (and did catch an error the first time around), but what's happening now doesn't quite seem like a syntax error. Basically, when I put the PHP code in the source of theme.html, it gets output on the final pagein the code as though it didn't get executed, just printed. So here's a sample of what I'm inputting...and when I view the pace, the source looks exactly like this:

CODE:
<td align="left">
<?php
$here = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
if(strpos($here, 'modules/news')===true) {
// News/home page.
$box = 'box-home.swf';
$image = '';
} else {
// Default page.
$box = 'box-home.swf';
$image = 'Rene_Antonio_Intro.swf';
}
?>
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/swflash.cab#version=6,0,29,0" width="222" height="197">
<param name="movie" value="http://dev.yellowdress.net/rene/themes/rene_v2_4//flash/<?php echo $box; ?>" " />
<param name="quality" value="high" />
<embed src="http://dev.yellowdress.net/rene/themes/rene_v2_4//flash/<?php echo $box; ?>" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="222" height="197"></embed>
</object>
</td>

4
Lance_
Re: Using PHP within a Theme File
  • 2006/3/1 0:24

  • Lance_

  • Home away from home

  • Posts: 983

  • Since: 2004/1/12


Well here's what I do.

I put my code in a .php file in the theme folder, then use an html include syntax where you want the code.

<{include file="mytheme/myfile.php"}>

I guess php in the html file really doesn't work.

Cheers
GDL-Web.com :: Website development.
Xoopslance.com::Freelancing and Projects
thelionsden-arena.net:: Clan/League/Ladder Hosting

5
TottoBG
Re: Using PHP within a Theme File
  • 2006/3/2 22:32

  • TottoBG

  • Not too shy to talk

  • Posts: 111

  • Since: 2005/8/18


Clean PHP in a clean HTML file won't work at all. But using XOOPS you're able to take advantage of the Smarty Template Engine that comes with it. So including php scripts as mentioned by Lance_ with the Smarty <{include .. }> tag or putting php code inside Smarty <{php}>..<{/php}> tags is possible.

6
Lance_
Re: Using PHP within a Theme File
  • 2006/3/3 1:37

  • Lance_

  • Home away from home

  • Posts: 983

  • Since: 2004/1/12


Sweet, didn't know about the smarty tags for php.

Thanks for the info.
GDL-Web.com :: Website development.
Xoopslance.com::Freelancing and Projects
thelionsden-arena.net:: Clan/League/Ladder Hosting

Login

Who's Online

197 user(s) are online (118 user(s) are browsing Support Forums)


Members: 0


Guests: 197


more...

Donat-O-Meter

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

Latest GitHub Commits