[rwfphp-developers] MultiContainer
Status: Beta
Brought to you by:
kaibab
|
From: Berend D. <cyb...@sp...> - 2004-09-13 16:37:26
|
Hi,
I finally got back to my projects and I think I know what is going
wrong... I tried to build a control that contains multiple other
controls but only displays one at a time. This way I can design a skin
with only one variable in the Smarty template that switches controls
depending on what the user is doing. (Perhaps this can be done in
another way but I thought the easiest way was to simply switch between
controls).
Anyhow, this is the code which fucks it up (the controls inside this
container don't get their proper name - like we allready found out).
<?php
require_once(RWF_DIR.'rwf/Web/UI/WebControls/WebControl.class.php');
class MultiContainer extends WebControl {
var $controls;
var $select;
function MultiContainer() {
WebControl::WebControl();
$this->controls = array();
$this->select = 0;
}
function addControl(/* Control */ $control) {
$this->controls[count($this->controls)] = &$control;
}
function setVisible(/* number */ $n) {
if (!is_numeric($n)) return $this->setVisibleByName($n);
if ($n >= 0 && $n <= count($this->controls) - 1) {
$this->select = $n;
}
}
function setVisibleByName($name) {
for ($i = 0; $i < count($this->controls); $i++) {
if ($this->controls[$i]->Name == $name) return
$this->setVisible($i);
}
}
function GetTemplate($smarty) {
if (count($this->controls) == 0) return "[Empty container]";
return $this->controls[$this->select]->getTemplate($smarty);
}
/*function ConstructName() {
if (count($this->controls) != 0) return
$this->controls[$this->select]->ConstructName();
}*/
}
?>
Hope we can sort this out.
Berend Dekens
aka Cyberwizzard
|