PDA

View Full Version : save html code in variables to call in templates


Rouzbeh1
11-14-2006, 05:44 PM
hi
i want to store some html code in a variable and call them in the template.
how do i do this?

example :

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td align="center" valign="middle">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="middle" class="bar" style="height: 25px;">
<table class="tborder" cellpadding="4" cellspacing="1" width="100%">
<tr>
<td class="vbmenu_control"><a href="pbsms.php">$vbphrase[pbsms_overview]</a></td>
<td class="vbmenu_control"><a href="konto.php">$vbphrase[pbsms_manageacct]</a></td>
<td class="vbmenu_control">
<!--a href="sms.php">$vbphrase[pbsms_smsbox]</a-->
<!-- start vBMenu control element -->
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td id="SMSBox" class="vbmenu_control"><a href="#">$vbphrase[pbsms_smsbox]</a>
<script type="text/javascript">
<!--
vbmenu_register("SMSBox");
//-->
</script>
</td>
</tr>
</table>
<!-- end vBMenu control element -->
<!-- start vBMenu popup element -->
<div class="vbmenu_popup" id="SMSBox_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="thead" align="left">$vbphrase[pbsms_smsbox]</td>
</tr>
<tr>
<td class="vbmenu_option" align="left"><a href="sms.php?do=smsin">$vbphrase[pbsms_inbox]</a></td>
</tr>
<tr>
<td class="vbmenu_option" align="left"><a href="sms.php?do=smsout">$vbphrase[pbsms_outbox]</a></td>
</tr>
</table>
</div>
<!-- end vBMenu popup element -->

</td>
<td class="vbmenu_control"><a href="konto.php">$vbphrase[pbsms_mysms]</a></td>
<td class="vbmenu_control"><a href="adresses.php">$vbphrase[pbsms_addressbook]</a></td>
<td class="vbmenu_control"><a href="options.php">$vbphrase[pbsms_settings]</a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center" valign="top" height="409" style="height: 409px;">
<div style="height: 409px; overflow:auto;" class="content">
<script type="text/javascript">
<!--
image1 = new Image();
image1.src = "images/pbsms/smsmain_n.png";
image2 = new Image();
image2.src = "images/pbsms/mysms_n.png";
image3 = new Image();
image3.src = "images/pbsms/adresses_n.png";
image4 = new Image();
image4.src = "images/pbsms/credits_n.png";
image5 = new Image();
image5.src = "images/pbsms/preference_n.png";
image6 = new Image();
image6.src = "images/pbsms/logout_n.png";
//-->
</script>
<div align="center">
<table border="0" cellspacing="10" cellpadding="2" >
<tr valign="top">
<td width="120" height="60" valign="bottom" align="center"><a href="sms.php?session={$session}"><img name="smsmain" src="images/pbsms/smsmain_m.png" onmouseover = "document.smsmain.src = 'images/pbsms/smsmain_n.png'" onmouseout = "document.smsmain.src = 'images/pbsms/smsmain_m.png'" alt="$vbphrase[pbsms_smsbox]" border="0" /></a><br /><b>$vbphrase[pbsms_smsbox]</b></td>
<td width="120" height="60" valign="bottom" align="center"><a href="main.php?do=mysms&amp;session={$session}"><img name="mysms" src="images/pbsms/mysms_m.png" onmouseover = "document.mysms.src = 'images/pbsms/mysms_n.png'" onmouseout = "document.mysms.src = 'images/pbsms/mysms_m.png'" alt="$vbphrase[pbsms_mysms]" border="0" /></a><br /><b>$vbphrase[pbsms_mysms]</b></td>
<td width="120" height="60" valign="bottom" align="center"><a href="adresses.php?session={$session}"><img name="adresses" src="images/pbsms/adresses_m.png" onmouseover = "document.adresses.src = 'images/pbsms/adresses_n.png'" onmouseout = "document.adresses.src = 'images/pbsms/adresses_m.png'" alt="$vbphrase[pbsms_addressbook]" border="0" /></a><br /><b>$vbphrase[pbsms_addressbook]</b></td>
</tr>
<tr>
<td width="120" height="60" valign="bottom" align="center"><a href="konto.php?session={$session}"><img name="credits" src="images/pbsms/credits_m.png" onmouseover = "document.credits.src = 'images/pbsms/credits_n.png'" onmouseout = "document.credits.src = 'images/pbsms/credits_m.png'" alt="$vbphrase[pbsms_manageacct]" border="0" /></a><br /><b>$vbphrase[pbsms_manageacct]</b></td>
<td width="120" height="60" valign="bottom" align="center"><a href="options.php?session={$session}"><img name="prefs" src="images/pbsms/preference_m.png" onmouseover = "document.prefs.src = 'images/pbsms/preference_n.png'" onmouseout = "document.prefs.src = 'images/pbsms/preference_m.png'" alt="$vbphrase[pbsms_settings]" border="0" /></a><br /><b>$vbphrase[pbsms_settings]</b></td>
<td width="120" height="60" valign="bottom" align="center"><a href="main.php?do=logout&amp;session={$session}" onclick="return(confirm('M?chten Sie sich wirklich ausloggen?'));"><img name="logout" src="images/pbsms/logout_m.png" onmouseover = "document.logout.src = 'images/pbsms/logout_n.png'" onmouseout = "document.logout.src = 'images/pbsms/logout_m.png'" alt="Logout" border="0" /></a><br /><b>Logout</b></td>
</tr>
</table>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
$footer
</body>
</html>


this code :

<!-- start vBMenu control element -->
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td id="SMSBox" class="vbmenu_control"><a href="#">$vbphrase[pbsms_smsbox]</a>
<script type="text/javascript">
<!--
vbmenu_register("SMSBox");
//-->
</script>
</td>
</tr>
</table>
<!-- end vBMenu control element -->
<!-- start vBMenu popup element -->
<div class="vbmenu_popup" id="SMSBox_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="thead" align="left">$vbphrase[pbsms_smsbox]</td>
</tr>
<tr>
<td class="vbmenu_option" align="left"><a href="sms.php?do=smsin">$vbphrase[pbsms_inbox]</a></td>
</tr>
<tr>
<td class="vbmenu_option" align="left"><a href="sms.php?do=smsout">$vbphrase[pbsms_outbox]</a></td>
</tr>
</table>
</div>
<!-- end vBMenu popup element -->


should get saved in a variable like $dhtml_menu and then i use it in some template....

Paul M
11-14-2006, 06:13 PM
Same as you would any other text ;

$var = ' <html> ';

Rouzbeh1
11-14-2006, 06:27 PM
isn't there any other way which is better?
i don't like to have html code in php files

Adrian Schneider
11-14-2006, 06:49 PM
eval('$var = "' . fetch_template('template_name') . '";');

Rouzbeh1
11-14-2006, 08:06 PM
eval('$var = "' . fetch_template('template_name') . '";');

wow
that's exactly what i wanted to know

thanks:cool: