SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: phplib blocks

  1. #1
    SitePoint Zealot sifuhall's Avatar
    Join Date
    Jun 2001
    Location
    out of the sidehatch
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    phplib blocks

    I'm attempting to use phplib templates and here is what I have in the template:

    Code:
    <table border="1">
    
    <!-- BEGIN FolderBlock -->
    	<tr>
    		 <td>{name}</td>
    	</tr>
    <!-- END FolderBlock -->
    
    </table>
    The code that populates this is:
    Code:
    $t = new Template();
    $t->set_file("MyFileHandle","templates/messagefolders.html");
    $t->set_block('MyFileHandle', 'FolderBlock', 'FBlock'); 
    $t->set_var('name', $test['0']->name); 
    $t->Parse('FBlock', 'FolderBlock', true); 
    $t->pparse("MyOutput","MyFileHandle");
    However, the output is:
    Code:
    <table border="1">
    
    FBlock
    
    </table>
    What am I missing? Inside $test['0'] is the word Inbox.

    Also, what happened to my <tr><td>etc.?

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It doesn't seem to be a problem with the template or code, but with the value of the var $test['0']->name. Also if all you are doing is setting one var, you don't need to use a block.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Zealot sifuhall's Avatar
    Join Date
    Jun 2001
    Location
    out of the sidehatch
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply.

    I originally had may values in $test['0'], but reduced it to one in an attempt to debug.

    This is still baffling to me. I copied the devshed tutorial code and look at my results:

    PHP script:
    Code:
    <?  
    include_once "template.inc"; 
    $T = new Template();
    $T->set_file('input_two', 'two.ihtml'); 
    $T->set_block('input_two', 'AccessBlock', 'ABlock'); 
    
    $want_list=array(
    	0 => 'Baseball bat', 
    	1 => 'Remote Control car', 
    	2 => 'Wagon'
    	); 
    
    for ($i=0; $i<sizeof($want_list); $i++) { 
    	$T->set_var('item', $want_list[$i]); 
    	$T->Parse('ABlock', 'AccessBlock', true); 
    	} 
    $T->pparse('Output', 'input_two'); 
    ?>
    HTML file:
    Code:
    A list of what I want for Christmas: 
    <OL>
    <!-- BEGIN AccessBlock --> 
    <LI> {item} 
    <!-- END AccessBlock --> 
    </OL>
    And here is the output:
    Code:
    A list of what I want for Christmas: 
    <OL>
    ABlock 
    </OL>
    I'm using PHP v. 4.0.3pl1 and only the template.inc from phplib.

  4. #4
    SitePoint Zealot sifuhall's Avatar
    Join Date
    Jun 2001
    Location
    out of the sidehatch
    Posts
    135
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Woo hoo!!!

    I found the answer here

  5. #5
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of phplib were you using?
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •