Categories > Your tips & tricks >

INI files (fr: fichier ini)

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Condutiarii
Date: 2004-11-25
Time: 00:55

INI files (fr: fichier ini)

Use an ini file to build menu / Utiliser un fichier ini pour construire un menu

test.ini :

#Start menu
[home]
label="Home"
link="index.php"
img="home.png"
title="Home page"
[news]
label="News"
link="news.php"
img="newspaper.gif"
title="News of TBS development"
[forum]
label="Forum"
link="forum.php"
img="tower.jpg"
title="The incredible forum"
#Etc...

You place your block following attributes in ini file / Vous placez votre bloc selon les attributs du fichier ini

test.htm :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" />
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=windows-1250" />
    <title>
      IniFile Source
    </title>
    <link rel="stylesheet" href="inc/style.css" type="text/css" />
  </head>
  <body>
    <ul>
      <li>
      <img src="[mnu.img;block=li]" title="[mnu.title]" />
      <a href="[mnu.link]" >[mnu.label]</a></li>
      <ul>
  </body>
</html>

test.php :

<?php
require_once('tbs_class.php');

function tbsdb_inifile_open(&$Source, &$Query)
{
  if (!file_exists($Query)) return false;
  return parse_ini_file($Query, TRUE);
}

function tbsdb_inifile_fetch(&$Rs)
{
  $buffer = array_shift($Rs);
  if (is_null($buffer)) $buffer = false;
  return $buffer;
}

function tbsdb_inifile_close(&$Rs)
{
  unset($Rs);
}

$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('test.htm');

$TBS->MergeBlock('mnu', 'inifile', 'test.ini');

$TBS->Show();
?>