By: Raptor
Date: 2007-04-13
Time: 18:37
|
Problems with MergeBlock and an arrayi got a problem merging an array to an block when using a dynamic query. when is use the syntax as described in the manual like
$tpl_test->MergeBlock('antwort','array','test[%p1%][antwort]'); i just get an empty page caus TBS seems to kill the script. when i use a syntax like $tpl_test->MergeBlock('antwort','array',$test[0][antwort]); it works. It seems the problem appears only when i use the source variable in "tbs string form". when i use it as normal PHP variable it works? So how can i fix this, caus i need the TBS syntax for using %p1% for my dynamic query? Im usinh PHP5 and TBS 3.0.2 |
|||
By: TomH
Date: 2007-04-13
Time: 23:41
|
Re: Problems with MergeBlock and an arrayFor reference... you need to show us the code for both the main and sub MergeBlock()... and the html template code...
I have example of what you are trying to do, here http://tomhenry.us/tbs3/ the source code might help you... Cheers, TomH |
|||
By: Raptor
Date: 2007-04-14
Time: 00:11
|
Re: Problems with MergeBlock and an arrayYep, thx Tom. Ive already found ur example at ur website by browsing through the board. I think i made it exactly the same way, but it doesnt works. Here the full Code:
the code works as long as i comment out the second MergeBlock or use a php there variable instead TBS syntax |
|||
By: TomH
Date: 2007-04-14
Time: 02:12
|
Re: Problems with MergeBlock and an arrayI struggled with the same symptoms in mine for a _long_ time.. turned out the problem was the template code organization
Show us your html template code... |
|||
By: Raptor
Date: 2007-04-14
Time: 10:13
|
Re: Problems with MergeBlock and an arrayaaalright, here we go ;-)
|
|||
By: TomH
Date: 2007-04-14
Time: 14:36
|
Re: Problems with MergeBlock and an arrayThe html looks okay to me, thanks for posting it.
All I can see is that the version of the sub MergeBlock does NOT contain the %p1% parameter - needed to pass the reference [frag.$] from the main query to the subquery Have you tried this arrangement...
|
|||
By: Raptor
Date: 2007-04-14
Time: 20:25
|
Re: Problems with MergeBlock and an arrayoh, i know it doesnt contain the parameter, it was just an example to show that it works when i use an php variable instead of writing it like 'xxx'. i already tried ur version before but the only thing i get is an empty page ... =(
|
|||
By: Pirjo Posio
Date: 2007-04-15
Time: 01:26
|
Re: Problems with MergeBlock and an arrayHi Raptor,
I believe your data is not an "array of arrays", like this: $test[0]['antwort'][] = array('topic'=>'dabadaba', 'value'=>'605'); $test[0]['antwort'][] = array('topic'=>'goo', 'value'=>'25'); That's why it only works with the php variable. |
|||
By: Raptor
Date: 2007-04-15
Time: 11:58
|
Re: Problems with MergeBlock and an arrayHm ur definition
|
|||
By: TomH
Date: 2007-04-15
Time: 15:04
|
Re: Problems with MergeBlock and an arrayHmmm... when all else fails there is value in checking assumptions.
I would follow Ms Pirjo's lead a bit more and look at the underlying data, dump the data so you can verify that the arrays are structured as expected. Something like this should work...
It might help us to help if you post that too. Keep on going, TomH |
|||
By: Raptor
Date: 2007-04-15
Time: 15:48
|
Re: Problems with MergeBlock and an arrayThats the result i get when dumping the variable. In my opinion its correct?
|
|||
By: Raptor
Date: 2007-04-15
Time: 15:54
|
Re: Problems with MergeBlock and an arraybtw, i still think it cant be my array, caus when i use the source parameter without apostrophes as normal php variable it works perfectly. it just hangs up when im using TBS syntax with apostrophes ...
|
|||
By: Pirjo Posio
Date: 2007-04-16
Time: 22:29
|
Re: Problems with MergeBlock and an arrayIf I had this problem, I might rearrange the data like this:
The merging part of the PHP code would be:
|
|||
By: Raptor
Date: 2007-04-17
Time: 14:43
|
Re: Problems with MergeBlock and an arraytried this one too. result stays the same .... when is use apostrophes the site hangs up and i get an empty page, when removing the apostrophes and using a php variable it works.
if its not a bug i guess TBS got some problems with my server maybe? |
|||
By: Pirjo Posio
Date: 2007-04-18
Time: 01:04
|
Re: Problems with MergeBlock and an arrayI'm sorry you could not be helped with my code. For me it works well, I tested it.
But, I use PHP4 and TBS 3.2.0. You said you use PHP5 and TBS 3.0.2. Why don't you use the latest version of TBS? The only thing I know is to check and recheck, that your quotes are in order. I prefer single quotes, as you can see from my code. Remember also to use that %p1% in your antwort-MergeBlock (or any sub-block). I cannot do more, since I don't have your environment. |
|||
By: Raptor
Date: 2007-04-19
Time: 14:37
|
Re: Problems with MergeBlock and an arrayFOR EVERYONE WHO GOT THE SAME PROBLEM, HERE´S THE SOLUTION:
The problem is how PHP5 handles variables! TBS can only work with global variables, but PHP5 do not handle variables without definition as global ones as PHP4 did. Variables without definition automatically becomes private ones. So u have simply to use
Greetz Raptor |
|||
By: Pirjo Posio
Date: 2007-04-20
Time: 08:19
|
Re: Problems with MergeBlock and an arrayCongratulations, Raptor, for finding the solution!
Your findings deserve the right to be put in the TBS manual, if it is not yet mentioned clearly, clearly, that with TBS and PHP5 one MUST specifically define the variables as global. And also in the Golden Rules. How is it, Skrol29? I know that you have reminded people of the need of global variables a thousand times... |