Categories > TinyButStrong general >

Display multiples

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: MightyRaven
Date: 2003-08-16
Time: 00:13

Display multiples

Hi,

sorry, i dont understand how to display many records seperatly like this :
Best example what i want to do : display many news like from PHPNuke
I display only once ! no really 3 news. plz explain to me. I dont want copy/paste this code for the others news

From Template file

<table summary="" class="d3" width="400" cellpadding="0" cellspacing="0">
<tr>
                                <td height="17" valign="top">
                                <table summary="" class="d3" cellspacing="1" cellpadding="2">
                                    <tr>
                                        <td bgcolor="#acc6dd" width="325" height="17" class="ne">&nbsp;<b>. :</b> [blnew.titre]</td>
                                        <td bgcolor="#41729e" width="75" height="17" class="ne"><div align="right">&nbsp;[blnew.date]&nbsp;</div></td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#ffffff" width="259" height="17" class="ne" colspan="2">&nbsp;[blnew.contenu]</td>
                                    </tr>
                                    <tr>
                                        <td bgcolor="#acc6dd" width="198" height="17" class="ne" colspan="2">&nbsp;<b>: .</b> posté par [blnew.auteur]</td>
                                    </tr>
                                </table>
                                </td>
                            </tr>
                        </table><br>


From PHP


<?

include_once("tbs_class.php") ;

//Connexion à la base de donnée
require($_SERVER["DOCUMENT_ROOT"].'/cnx_mysql.php');
//Le fichier cnx_mysql.php contiens les lignes suivnates :
//  $cnx_id = mysql_connect('localhost','user','password') ;
//  mysql_select_db('dbname',$cnx_id) ;

$TBS = new clsTinyButStrong ;
$TBS->LoadTemplate("page_template.htm") ;
$TBS->MergeBlock("blnew",$cnx_id,"SELECT * FROM news") ;
mysql_close($cnx_id) ;
$TBS->Show() ;

?>
By: Skrol29
Date: 2003-08-16
Time: 00:54

Re: Display multiples

Hello Mighty,

Your PHP code is ok, but your HTML template miss the block definition. You've got the fields but not the bounds.

There are several ways in TBS to define a block.
Here are different 3 solutions.

1/ the Mankiy's way.
The block is defined by a personal tag (here: <bldef1>).
This way is fine is you use a textual HTML editor. If you use a visual HTML editor, solutions 2 and 3 are more visible.
<table summary="" class="d3" width="400" cellpadding="0" cellspacing="0">
<bldef1>
<tr>
<td height="17" valign="top">
<table summary="" class="d3" cellspacing="1" cellpadding="2">
<tr>
<td bgcolor="#acc6dd" width="325" height="17" class="ne">&nbsp;<b>. :</b> [blnew.titre;block=bldef1]</td>
<td bgcolor="#41729e" width="75" height="17" class="ne"><div align="right">&nbsp;[blnew.date]&nbsp;</div></td>
</tr>
<tr>
<td bgcolor="#ffffff" width="259" height="17" class="ne" colspan="2">&nbsp;[blnew.contenu]</td>
</tr>
<tr>
<td bgcolor="#acc6dd" width="198" height="17" class="ne" colspan="2">&nbsp;<b>: .</b> posté par [blnew.auteur]</td>
</tr>
</table>
</td>
</tr>
</bldef1>
</table><br>

2/ use a main table
This solution is fine if you use a visual HTML editor.
The table is nested inside a main table.

<table border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>
            <table summary="" class="d3" width="400" cellpadding="0" cellspacing="0">
            <tr>
            <td height="17" valign="top">
            <table summary="" class="d3" cellspacing="1" cellpadding="2">
            <tr>
            <td bgcolor="#acc6dd" width="325" height="17" class="ne">&nbsp;<b>. :</b> [blnew.titre;block=table]</td>
            <td bgcolor="#41729e" width="75" height="17" class="ne"><div align="right">&nbsp;[blnew.date]&nbsp;</div></td>
            </tr>
            <tr>
            <td bgcolor="#ffffff" width="259" height="17" class="ne" colspan="2">&nbsp;[blnew.contenu]</td>
            </tr>
            <tr>
            <td bgcolor="#acc6dd" width="198" height="17" class="ne" colspan="2">&nbsp;<b>: .</b> posté par [blnew.auteur]</td>
            </tr>
            </table>
            </td>
            </tr>
            </table>
        </td>
  </tr>
</table>

3/ use the 'extend' parameter.
If you add some <tr> in your news block, you will have to increase the extend value.
<table summary="" class="d3" width="400" cellpadding="0" cellspacing="0">
  <tr>
    <td height="17" valign="top">
      <table summary="" class="d3" cellspacing="1" cellpadding="2">
        <tr>
          <td bgcolor="#acc6dd" width="325" height="17" class="ne">&nbsp;<b>.
              :</b> [blnew.titre;block=row;extend=2]</td>
          <td bgcolor="#41729e" width="75" height="17" class="ne"><div align="right">&nbsp;[blnew.date]&nbsp;</div>
          </td>
        </tr>
        <tr>
          <td bgcolor="#ffffff" width="259" height="17" class="ne" colspan="2">&nbsp;[blnew.contenu]</td>
        </tr>
        <tr>
          <td bgcolor="#acc6dd" width="198" height="17" class="ne" colspan="2">&nbsp;<b>:
              .</b> posté par [blnew.auteur]</td>
        </tr>
      </table>
    </td>
  </tr>
</table>