| 
	    
         By: martijn 
        Date: 2007-01-28 
        Time: 17:56 
		
	   | 
	  
      
	    Confused about arrays
        
        Hi all, 
I'm a bit confused about how to use arrays in TBS. 
I did read the manual but can't bring it into practice. 
Could you guys help me out? 
PHP part:
 
        case 'file_preview': 
            $status = 4; 
            $page_title = $portal->pageTitle('Review your release'); 
            // Put everything in a array 
            $data = array(); 
            $data['name'] = $_POST['progname']; 
            $data['ver'] = $_POST['progver']; 
            $data['desc'] = $_POST['progdesc']; 
            $data['website'] = $_POST['progweb']; 
            $tmpl->MergeBlock('review', 'array', $data); 
        break; 
 |  
 
And the HTML:
 
            <div class="content"> 
                [onload_status;block=div;when [var.status] = 4] 
                <h3 class="wimg">Review your release before submission:</h3> 
                <p>[review.name] [review.ver]</p> 
            </div> |  
 
I did try to use it like this: [review[name]] in HTML or $data['review']['name'] = $_POST['progname']; but neither method works.  
	   | 
	  
    
	
      | 
	    
         By: Skrol29 
        Date: 2007-01-28 
        Time: 20:15 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        The array you provide should be an array or arrays. 
 
	   | 
	  
    
	
      | 
	    
         By: martijn 
        Date: 2007-01-28 
        Time: 22:12 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        An array off arrays? 
	   | 
	  
    
	
      | 
	    
         By: TomH 
        Date: 2007-01-28 
        Time: 22:59 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        See the TBS Examples for array, like so 
PHP script
 include_once('tbs_class.php') ; 
 
$array_type1 = array('France'=>33, 'England'=>44, 'Spain'=>34, 'Italy'=>39, 'Deutchland'=>49) ; 
 
$array_type2[] = array('res_name'=>'Marie',  'res_score'=>300, 'res_date'=>'2003-01-10') ; 
$array_type2[] = array('res_name'=>'Eric', 'res_score'=>215, 'res_date'=>'2003-01-10') ; 
$array_type2[] = array('res_name'=>'Mark', 'res_score'=>180, 'res_date'=>'2003-01-10') ; 
$array_type2[] = array('res_name'=>'Paul', 'res_score'=>175, 'res_date'=>'2003-01-10') ; 
$array_type2[] = array('res_name'=>'Mat', 'res_score'=>120, 'res_date'=>'2003-01-10') ; 
$array_type2[] = array('res_name'=>'Sonia', 'res_score'=>115, 'res_date'=>'2003-01-10') ; 
 
$all_array['type1'] = $array_type1; 
$all_array['type2'] = $array_type2; 
 
$TBS = new clsTinyButStrong ; 
$TBS->LoadTemplate('tbs_us_examples_dataarray.htm') ; 
$TBS->MergeBlock('blk1',$array_type1) ; 
$TBS->MergeBlock('blk2',$array_type2) ; 
$TBS->MergeBlock('blk3','array','all_array[type2]') ; 
$TBS->Show() ; 
 |  
 
HTML template
 <table width="300" border="1" align="center" cellpadding="2" cellspacing="0"> 
  <tr bgcolor="#CACACA"> 
    <td width="30"><strong>Position</strong></td> 
    <td><strong>Nickname</strong></td> 
    <td><strong>Score</strong></td> 
    <td><div align="center"><strong>Date</strong></div></td> 
  </tr> 
  <tr bgcolor="#F0F0F0"> 
    <td>[blk2.#]</td> 
    <td>[blk2.res_name;block=tr]</td> 
    <td><div align="right">[blk2.res_score]</div></td> 
    <td><div align="center">[blk2.res_date;frm='mm-dd-yy']</div></td> 
  </tr> 
  <tr bgcolor="#E6E6E6"> 
    <td>[blk2.#]</td> 
    <td>[blk2.res_name;block=tr]</td> 
    <td><div align="right">[blk2.res_score]</div></td> 
    <td><div align="center">[blk2.res_date;frm='mm-dd-yy']</div></td> 
  </tr> 
  <tr bgcolor="#FFCFB9"> 
    <td colspan="4">[blk2;block=tr;nodata]There is no data. </td> 
  </tr> 
 |  
  
HTH,  
	   | 
	  
    
	
      | 
	    
         By: martijn 
        Date: 2007-01-29 
        Time: 12:50 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        It still doesn't want to work :( 
        case 'file_preview': 
            $status = 4; 
            $page_title = $portal->pageTitle('Review your release'); 
            // Put everything in a array 
            $data = array('name'=> $_POST['progname']); 
            $tmpl->MergeBlock('review', $data); 
        break; 
 |  
  
And [review.name] in the source doesn't return a thing  
	   | 
	  
    
	
      | 
	    
         By: Skrol29 
        Date: 2007-01-29 
        Time: 16:47 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        Hi, 
In your first snippet, just replace :  | 
$tmpl->MergeBlock('review', 'array', $data); |  
 
with :  | 
$tmpl->MergeBlock('review', 'array', array($data)); |  
  
	   | 
	  
    
	
      | 
	    
         By: martijn 
        Date: 2007-01-30 
        Time: 15:48 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        Sorry, that still doesn't work :( 
I just don't get it... Could it be because of the post data? 
	   | 
	  
    
	
      | 
	    
         By: Skrol29 
        Date: 2007-01-31 
        Time: 00:34 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        Can you give information about the result you've got ? 
	   | 
	  
    
	
      | 
	    
         By: martijn 
        Date: 2007-01-31 
        Time: 07:29 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        It doesn't give any result. On loading the page it just displays the template data: [review.name] [review.ver]. 
Using the extract() function on the post variable helps, but an array is an cleaner solution.. 
	   | 
	  
    
	
      | 
	    
         By: Skrol29 
        Date: 2007-01-31 
        Time: 10:37 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        If fields [review.name] and [review.ver] are not merged and there is no TBS error message then $tmpl->MergeBlock('review',...) has not been run. 
Can you check that this line is executed by adding something like echo "flag" just before the MergeBlock() ? 
	   | 
	  
    
	
      | 
	    
         By: Pirjo Posio 
        Date: 2007-01-31 
        Time: 21:03 
		
	   | 
	  
      
	    Re: Confused about arrays
        
        Or could it be possible, that you have not this line in your code after the MergeBlock() Skrol29 is talking about? It's not in your original code before "break"... 
 
	   | 
	  
    
	
    
	
    
       | 
      
	    
		
         
		  Posting in progress. 
          Please wait...
		 
		
	   |