PHP variables in templates

Tutorials for <a href="http://www.phpbbstyles.com/viewtopic.php?t=356">eXtreme Styles mod</a> for phpBB 2.0.

Moderator: Moderators

Postby PostBot on Mon Apr 04, 2005 7:26 am

You forgot this code: global $forum_row;

Or try this:
Code: Select all
$forum_name = isset($GLOBALS['forum_row']) ? $GLOBALS['forum_row']['forum_name'] : (isset($GLOBALS['forum_name']) ? $GLOBALS['forum_name'] : '');
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby nix on Wed Apr 06, 2005 12:10 pm

ok i got it! tks!
nix
Registered User
Registered User
 
Posts: 2
Joined: Mon Apr 04, 2005 5:01 am

Postby USAF_Pride on Mon May 30, 2005 2:00 am

I've got this code that works as stand alone, but for some reason it isn't passing the variables through. Any ideas?
Code: Select all
<table width='200' CELLSPACING="0" CELLPADDING="0" meta http-equiv=Refresh content=60>
   <?php
   global $theip, $themap, $thenp, $themp, $webportal, $url, $lines, $lino;
   function MyHandler($errno, $errstr, $errfile, $errline, $errcontext) {
   }

   $webportal = "No";
   $url = "http://69.25.18.42:9080";
   $url_info=parse_url($url);
   $port = isset($url_info['port']) ? $url_info['port'] : 80;
   set_error_handler("MyHandler");
   if(fsockopen($url_info['host'], $port, $errno, $errstr, 30)) $webportal = "Yes";
   $servercontact ='';

     $url = "http://www.goaa.net/manager/status/xml.asp?server={8FD29937-FE88-46D5-A0F4-ECD4F32A4C28}";
     $lines = @file($url);
     if ($lines === false)
     {
       $servercontact='Server Unavailable';
     }
     else
     {

    foreach ($lines as $line_num => $line)
    {
      $lino = $line;
      if (preg_match("/<NAME>ipaddress<\/NAME>/i", $lino))
      {
        $theip = str_replace("ipaddress", "", htmlspecialchars(strip_tags($lines[$line_num])));
      }

      if (preg_match("/<NAME>mapname<\/NAME>/i", $lino))
      {
        $themap = htmlspecialchars(strip_tags($lines[$line_num+1]));
      }

      if (preg_match("/<NAME>numplayers<\/NAME>/i", $lino))
      {
        $thenp = htmlspecialchars(strip_tags($lines[$line_num+1]));
      }

      if (preg_match("/<NAME>maxplayers<\/NAME>/i", $lino))
      {
        $themp = htmlspecialchars(strip_tags($lines[$line_num+1]));
      }
    }

     }
      print "<tr> Server: AASA | =DM= Honor Server </tr>";
      echo "<tr> Server IP: $theip </tr>";
      print "<tr> Map: $themap </tr>";
      print "<tr> Players: $thenp / $themp </tr>";
      print "<tr> Banlists Loaded: $webportal </tr>";
   ?>
</table>


$theip, $themap, $thenp, $themp are not coming through for some reason.

thanks
USAF_Pride
Registered User
Registered User
 
Posts: 3
Joined: Mon May 30, 2005 1:55 am

Postby PostBot on Mon May 30, 2005 8:55 am

Where those variables should be coming from? If from url then you should use $_GET['theip'], etc.. because register_globals is disabled with phpBB.
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby PostBot on Mon May 30, 2005 10:28 am

Nevermind. I didn't look at script close enough.

Are you using that tpl file on same server where you have tested standalone script?
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Postby USAF_Pride on Mon May 30, 2005 12:21 pm

[quote user="CyberAlien" post="37188"]Nevermind. I didn't look at script close enough.

Are you using that tpl file on same server where you have tested standalone script?[/quote]

Yes, If I call it as a standalone script it seems to work. How do I handle the 30 second timeout if no response is recieved? When it timeouts, it prevents the rest of the page to load.
USAF_Pride
Registered User
Registered User
 
Posts: 3
Joined: Mon May 30, 2005 1:55 am

Postby PostBot on Mon May 30, 2005 12:55 pm

To handle timeout use set_time_limit() function: http://ch.php.net/set_time_limit
And that script looks fine, so I don't know what could be causing problem. Try adding some debug data in it to test what's going on.
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Use of tokens IF...ENDIF

Postby fgh on Mon Jun 06, 2005 10:45 pm

Hello

This mod is just great ! Thanks for sharing your developments.

The features list mention the tokens IF, ELSEIF, ELSE, ENDIF, DEFINE, UNDEFINE, but I coudn't find their description and use...
I assume one can use that tokens in the templates... but what is the syntax ?

Thanks for your help
fgh
Registered User
Registered User
 
Posts: 1
Joined: Mon Jun 06, 2005 10:38 pm

Postby PostBot on Tue Jun 07, 2005 7:30 am

Here are few examples:
Code: Select all
<!-- IF U_INDEX -->
<!-- IF postrow.POSTER_AVATAR -->
<!-- IF ! postrow.POSTER_AVATAR -->
<!-- IF postrow.POSTER_NAME == 'Test' -->
<!-- IF postrow.POSTS == 2 -->
<!-- ELSEIF postrow.POSTS > 2 -->
<!-- DEFINE $VAR = 'Testing' -->
<!-- UNDEFINE $VAR -->
<!-- IF $VAR == 'Testing' -->$VAR = {$VAR}<!-- ENDIF -->
Do NOT pm me, I don't visit this forum anymore, don't own it, don't provide any support and don't moderate.
User avatar
PostBot
Moderator
Moderator
 
Posts: 10659
Joined: Sat Aug 02, 2003 3:52 pm
Location: Mars

Very New

Postby Smoothice on Thu Jul 07, 2005 5:05 am

problem solved sorry guys
Smoothice
Registered User
Registered User
 
Posts: 2
Joined: Thu Jul 07, 2005 4:59 am

switch_*

Postby MrPrise on Tue Dec 27, 2005 11:38 am

Hello!

How can I use the switch_* variables in the included PHP code int a .tpl file?

Thx
MrPrise
Registered User
Registered User
 
Posts: 2
Joined: Tue Dec 27, 2005 11:28 am

Re: switch_*

Postby MrPrise on Tue Dec 27, 2005 12:42 pm

[quote user="MrPrise" post="62189"]How can I use the switch_* variables in the included PHP code int a .tpl file?
[/quote]
I found the solution:
Code: Select all
global $userdata;
var_dump($userdata,TRUE);
MrPrise
Registered User
Registered User
 
Posts: 2
Joined: Tue Dec 27, 2005 11:28 am

Edit local style based on post subject

Postby jarrod on Wed Jan 04, 2006 11:01 pm

This might seem a strange one, basically I'd like to change the padding of a span tag based on the name of the post.
In this example I would like any post with the name "Photo" to have no padding and any other, a padding of 3px.

I know I must be close, this is what I have so far

Code: Select all
<td width="100%" height="28" valign="middle" bgcolor="#FFFFFF">
<?php 
global $POST_SUBJECT;
if ($POST_SUBJECT == "Photo")
{   
echo '<span style="margin:0px;" class="postbody">';   
}
else
{   
echo '<span style="margin:3px;" class="postbody">';   
}
?>
       {postrow.MESSAGE}</span>{postrow.ATTACHMENTS}
      </td>
jarrod
Registered User
Registered User
 
Posts: 10
Joined: Wed Jan 04, 2006 10:57 pm

Postby UseLess on Wed Jan 04, 2006 11:23 pm

Greetings,

[code start="2"]<?php
if( $this->vars['POST_SUBJECT'] == 'Photo' )[/code]

As 'POST_SUBJECT' is a template variable, NOT a php variable.
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Getting closer

Postby jarrod on Wed Jan 04, 2006 11:30 pm

Thankyou for your speedy response, although I can't say it's working.
Do I need to declare anything as global?
jarrod
Registered User
Registered User
 
Posts: 10
Joined: Wed Jan 04, 2006 10:57 pm

PreviousNext

Return to eXtreme Styles mod tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron