Php function that generate a custom layout pattern

Hi, I have created a function that generate a layout like 3J where the first column can have many cells. It work until 8 cell for the first column, for more cell there are problems. If I create a layout with 9 or more cells at first column I can see only the first 8. I attaches the php script.
The usage is:

[code]

[/code]

Function:

[code]
function generaTemplate($num) {
$total = $num+1; //Totale righe
$out = “<autosize hor="c1”;
for($i=0;$i<$num;$i++)
$out .= “;c”.($i+2);
$out .= “" ver="c0;c$total" rows="$total" cols="2"/>”;
$out .= “<table data="c0,c1”;
for($i=0;$i<$num;$i++)
$out .= “;c0,c”.($i+2);
$out .= “"/>”;
$out .= “<cell obj="c1" wh="2,$total" resize="ver" neighbors="c1”;
for($i=0;$i<$num;$i++)
$out .= “;c”.($i+2);
$out .= “"/>”;
$out .= “<cell sep="ver" right="c0" left="c1”;
for($i=0;$i<$num;$i++)
$out .= “,c”.($i+2);
$out .= “" dblclick="c1" rowspan="”.($total+4).“"/>”;
$out .= “<cell obj="c0" wh="2,1" resize="hor" neighbors="c0;c1”;
for($i=0;$i<$num;$i++)
$out .= “;c”.($i+2);
$out .= “" rowspan="”.($total+4).“"/>”;
$out .= “”;
// Creo una riga per ogni categoria e un separatore di riga
for ($j=0;$j<$num;$j++) {
$out .= “<row sep="yes">”;
$out .= “<cell sep="hor" top="c1”;
for ($i=1;$i<($j+1);$i++)
$out .= “;c”.($i+1);
$out .= “" bottom="c”.($j+2);
for ($i=($j+2);$i<$total;$i++)
$out .= “;c”.($i+1);
$out .=“" dblclick="c1"/>”;
$out .=“<cell obj="c”.($j+2).“" wh="2,$total" resize="ver" neighbors="c1”;
for($i=2;$i<=$total;$i++)
$out .= “;c$i”;
$out .=“"/>”;
}
$out .=“”;

	$result = "dhtmlXLayoutObject.prototype.tplData[\"CUSTOM\"] = '$out';dhtmlXLayoutObject.prototype._availAutoSize[\"CUSTOM_hor\"] = new Array(\"c0\"";
	for ($i=1;$i<($total+2);$i++) 
		$result .= ",\"c$i\"";
	$result .="); dhtmlXLayoutObject.prototype._availAutoSize[\"CUSTOM_ver\"] = new Array(\"c0";
	for ($i=1;$i<($total+2);$i++) 
		$result .= ";c$i";
	$result .= "\");";
	
	
	
	return $result;
}[/code]

Please help me.

You are setting incorrect rowspan. It should consider separators:
rowspan="".($total+$num)."

isntead of rowspan="".($total+4)."

Also you need to check the autosize configuration

Thanks very much for replay. Can you also help me for autosize? do you have ad example to better understand how to set autosize? My layout is simple, I have 2 columns, the first columns is split in X rows/cell and the second column has only 1 cell.
Regards

Please have a look at the 4G pattern:

dhtmlXLayoutObject.prototype._availAutoSize[“4G_hor”] = new Array(“a;b;c”,“d”);
dhtmlXLayoutObject.prototype._availAutoSize[“4G_ver”] = new Array(“a;d”,“b;d”,“c;d”);

Moreover, the neighbors attribute for the “d” cell (c0 in your pattern) are defined as follows:

a,b,c - cells at the left; d - in the right.

Hi, I have changed the procedure as you told me, but the result is that now I can see 9 cell in the first column instead of 11. Where is the error?

[code]
function generaTemplate($num) {
$total = $num+1; //Totale righe
$out = “<autosize ver=“c2”;
for($i=1;$i<$num;$i++)
$out .= “;c”.($i+2);
$out .= “” hor=“c0” rows=”$total" cols=“2”/>";
$out .= “<table data=“c0,c1”;
for($i=0;$i<$num;$i++)
$out .= “;c0,c”.($i+2);
$out .= “”/>”;
$out .= “<cell obj=“c1” wh=“2,$total” resize=“ver” neighbors=“c1”;
for($i=0;$i<$num;$i++)
$out .= “;c”.($i+2);
$out .= “”/>”;
$out .= “<cell sep=“ver” right=“c0” left=“c1”;
for($i=0;$i<$num;$i++)
$out .= “,c”.($i+2);
$out .= “” dblclick=“c1” rowspan=”".($total+$num).""/>";
$out .= “<cell obj=“c0” wh=“2,1” resize=“hor” neighbors=“c0;c1”;
for($i=0;$i<$num;$i++)
$out .= “;c”.($i+2);
$out .= “” rowspan=”".($total+($total-1)).""/>";
$out .= “”;
// Creo una riga per ogni categoria e un separatore di riga
for ($j=0;$j<$num;$j++) {
$out .= “<row sep=“true”>”;
$out .= “<cell sep=“hor” top=“c1”;
for ($i=1;$i<($j+1);$i++)
$out .= “;c”.($i+1);
$out .= “” bottom=“c”.($j+2);
for ($i=($j+2);$i<$total;$i++)
$out .= “;c”.($i+1);
$out .=”" dblclick=“c”.($j+1).""/>";
$out .="<cell obj=“c”.($j+2)."" wh=“2,$total” resize=“ver” neighbors=“c1”;
for($i=2;$i<=$total;$i++)
$out .= “;c$i”;
$out .=""/>";
}
$out .="";

	$result = "dhtmlXLayoutObject.prototype.tplData[\"CUSTOM\"] = '$out';dhtmlXLayoutObject.prototype._availAutoSize[\"CUSTOM_hor\"] = new Array(\"c1";
	for ($i=1;$i<($total+1);$i++) 
		$result .= ";c$i";
	$result .="\",\"c0\"); dhtmlXLayoutObject.prototype._availAutoSize[\"CUSTOM_ver\"] = new Array(\"c1;c0\"";
	for ($i=2;$i<($total+1);$i++) 
		$result .= ",\"c$i;c0\"";
	$result .= ");";
	
	
	
	return $result;
}[/code]

Hi,

I have changed the procedure as you told me

I’ve just pointed to the ready template. And did not provide the ready solution in the previous reply.

Please provide the pattern that you got in the result.

Hello, ther result patter is this.

[code]



































































dhtmlXLayoutObject.prototype._availAutoSize[“CUSTOM_hor”] = new Array(“c1;c2;c3;c4;c5;c6;c7;c8;c9;c10;c11”,“c0”);
dhtmlXLayoutObject.prototype._availAutoSize[“CUSTOM_ver”] = new Array(“c1;c0”,“c2;c0”,“c3;c0”,“c4;c0”,“c6;c0”,“c7;c0”,“c8;c0”,“c9;c0”,“c11;c0”);[/code]

Alexandra please help me :slight_smile: