![]()
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
<?php
// wcf imports
require_once(WCF_DIR.'lib/page/AbstractPage.class.php');
/**
* Minecraft ServerStatus
*
* @author Sorry
* @copyright fightcraft.de
* @package no
* @license ask admin@fightcraft.de
*/
class ServerStatusPage extends AbstractPage {
// system
public $templateName = 'serverstatus';
function __construct() {
parent::__construct();
//$error = 'error';
//$item1 = 'item1';
//$item2 = 'item2';
$item1 = 'test';
$item2 = 'test';
WCF::getTPL()->assign(array(
'item1' => $item1,
'item2' => $item2
));
}
}
|
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<?php
// wcf imports
require_once(WCF_DIR.'lib/page/AbstractPage.class.php');
/**
* Minecraft ServerStatus
*
* @author Sorry
* @copyright fightcraft.de
* @package no
* @license ask admin@fightcraft.de
*/
class ServerStatusPage extends AbstractPage {
// system
public $templateName = 'serverstatus';
//$error = 'error';
//$item1 = 'item1';
//$item2 = 'item2';
$item1 = 'test';
$item2 = 'test';
WCF::getTPL()->assign(array(
'item1' => $item1,
'item2' => $item2
));
}
|
This post has been edited 1 times, last edit by "Sorry" (Feb 10th 2012, 8:33pm)
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
<?php
// wcf imports
require_once(WCF_DIR.'lib/page/AbstractPage.class.php');
/**
* Minecraft ServerStatus
*
* @author Sorry
* @copyright fightcraft.de
* @package no
* @license ask admin@fightcraft.de
*/
class ServerStatusPage extends AbstractPage {
// system
public $templateName = 'serverstatus';
/**
* @see Page::readData()
*/
public function readData() {
$item1 = 'test';
$item2 = 'test';
parent::readData();
}
/**
* @see Page::assignVariables()
*/
public function assignVariables() {
WCF::getTPL()->assign(array(
'item1' => $item1,
'item2' => $item2
));
parent::assignVariables();
}
}
?>
|
I realised that with OOP too but it's seems to be much more complicated...
|
|
PHP Source code |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
<?php
// wcf imports
require_once(WCF_DIR.'lib/page/AbstractPage.class.php');
/**
* Minecraft ServerStatus
*
* @author Sorry
* @copyright fightcraft.de
* @package no
* @license ask admin@fightcraft.de
*/
class ServerStatusPage extends AbstractPage {
// system
public $templateName = 'serverstatus';
public $item1 = '';
public $item2 = '';
/**
* @see Page::readData()
*/
public function readData() {
parent::readData();
$this->item1 = 'test1';
$this->item2 = 'test2';
}
/**
* @see Page::assignVariables()
*/
public function assignVariables() {
parent::assignVariables();
WCF::getTPL()->assign(array(
'item1' => $this->item1,
'item2' => $this->item2
));
}
}
?>
|
It is not. If you're familiar with PHP you might know about variable scope, which means that you cannot access a variable defined outside a function unless you import it with "global" or pass it as argument. Try the example below, it works and shows you how to carry variables across different functions.
|
|
PHP Source code |
1 |
{if isArray($infovalue)}{foreach from=infovalue item=value}{$value}<br/>{/foreach}{/if}
|
|
|
PHP Source code |
1 |
{if $infovalue|is_array{*}don't know if that exists{*}}{foreach from=infovalue item=value}{$value}<br/>{/foreach}{/if}
|
This post has been edited 3 times, last edit by "Sorry" (Feb 10th 2012, 10:50pm)
|
|
PHP Source code |
1 2 3 |
public $array = array();
public $string = '';
public $integer = 0;
|
This post has been edited 1 times, last edit by "Christopher Walz" (Feb 11th 2012, 12:28am)
Forum Software: Burning Board® 3.1.7, developed by WoltLab® GmbH