Filesoup
X   Site Message
(Message will auto close in 2 seconds)


> 

If you would like to advertise your Hosting, Services or Products on Filesoup, please contact Geeker for a quote.

 
Reply to this topicStart new topic
> Templating system
StirolXXX
post Yesterday, 07:46 PM
Post #1


Yuna Scatari
Group Icon

Group: Member
Posts: 160
Joined: 3-March 06
From: Ukraine
Member No.: 362,582
 


May'be someone need this wink.gif

It will convert this:

QUOTE
<div id="footer">Powered by vBulletin template system</div>
<if condition="$CURUSER">
Thanks for logging in...
</if>


To this:

CODE
<div id=\"footer\">Powered by vBulletin template system</div>
".(($GLOBALS['CURUSER']) ? ("
Thanks for logging in...
") : (""))."


So it can be included in eval... i.e this is somekinda vs own version of vBulletin-style templates.

My small example:

CODE
$header = fetch_template("template_test");
$countries = fetch_template("countries");
$footer = fetch_template("footer_test");

$header = compile_template($header);
$countries = compile_template($countries);
$footer = compile_template($footer);

$res = sql_query("SELECT name, flagpic FROM countries");

while ($c = mysql_fetch_array($res)) {
    $name = $c["name"];
    $flag = "<img src=\"pic/flag/$c[flagpic]\" border=\"0\" />";
    eval("\$countries_data .= \"".compile_template(fetch_template("countries_bit"))."\";");
}

header("Cache-Control: no-cache");
header("Pragma: no-cache");

eval("\$countries = \"".$countries."\";");
eval("\$footer = \"".$footer."\";");
eval("\$header = \"".$header."\";");

$use_blocks = 0;

echo $header;


Attached file is the functions itself.

You may need to modify fetch_template() to get the data not from variable but from somewhere else... wink.gif

Sample template:

footer_test:

CODE
<div id="footer">Powered by vBulletin template system</div>
<if condition="$CURUSER">
Thanks for logging in...
</if>


template_test:

CODE
<html dir="ltr" lang="ru">
<head>
    <!-- no cache headers -->
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="-1" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <!-- end no cache headers -->
    <title>Powered by vBulletin template system</title>
    &lt;script language="javascript" type="text/javascript" src="js/tooltips.js"></script>
    <style type="text/css">
    html, body {
        /*margin: 0;
        padding: 0;*/
        border: none;
    }
    #footer {
        border-top: dashed 1px #5087AD;
    }
    #tooltip {
        background: #ffffff;
        font: verdana;
        font-size: 10px;
        width:auto;
        border:1px solid #778899;
        border-left:5px solid #ff9f00;
        color: #333333;
        font-family: verdana, arial, helvetica, sans-serif;
        opacity: 0.91;
        filter: alpha(opacity="91");
        line-height:15px;
        z-index:100;
        margin:0px;
        padding: 3px;
        position: absolute;
        visibility: hidden;
        border-collapse: separate;
    }
    </style>
</head>
<body>
$countries
$footer
</body>
</html>


countries:

CODE
<table>$countries_data</table>


countries_bit:

CODE
<tr><td>$name</td><td>$flag</td></tr>


What do you think about my develop?
Attached File(s)
Attached File  template.php ( 13.37k ) Number of downloads: 2
 


--------------------
Page generated in 0.010832 seconds with 0 queries (100.00% PHP / 0.00% MySQL)
On clean page, sessions disabled, without blocks, without IP-bans, without GZip and as the guest.

TBDev Yuna Scatari Edition is the fastest TBDev source avialable - http://bit-torrent.kiev.ua/
No XBT required! Only PHP + mySQL!

http://www.kinoclub.org/torrentbar/bar.php/80805.png
Go to the top of the pageReport Post
+
StirolXXX
post Yesterday, 09:29 PM
Post #2


Yuna Scatari
Group Icon

Group: Member
Posts: 160
Joined: 3-March 06
From: Ukraine
Member No.: 362,582
 


expert01, i hope this helps you out in Torrential! wink.gif
Go to the top of the pageReport Post
+

Fast ReplyReply to this topicStart new topic
1 User(s) are reading this topic (0 Guests and 0 Anonymous Users)
1 Members: OPPZeroCool

 




Restaurant Equipment | Photo Gallery | Remortgages | Just Holden Commodores | Kingdom Hearts
-
Lo-Fi Version 0.1249 sec    --    13 queries    GZIP Enabled
Time is now: 27th June 2007 - 06:19 PM