webForumDet fria alternativet

Lagra fler funktioner i include?

PHPur PHP

2 svar · 195 visningar · startad av Hallgren

Medlem sedan dec. 19991 606 inlägg
Frågan#1

Yo!

Hur man jag lagra fler taggar i en include fil och sedan hämta dem?

Typ om jag vill kunna ändra bgcolor och vill ha alla alternativ i en include fil.

------------------
Forumledare, webForum

Medlem sedan mars 20007 896 inlägg
#2

Typ:

:: includeFilen.php
----
<?php
define("BGCOLOR", "black");
define("TEXTCOLOR", "green");
?>
----
:: phpFilen.php
----
<?php
require "includeFilen.php";
php, php, php
?>
<html>
<body bgcolor="<?php BGCOLOR; ?>">
</body>
</html>
----
----
[red][b]Eller[/b][/red]:
----
:: includeFilen.php
----
<?php
bgcolor = "black";
textcolot = "green";
?>
----
:: phpFilen.php
----
<?php
require "includeFilen.php";
php, php, php
?>
<html>
<body bgcolor="<?php $bgcolor; ?>">
</body>
</html>

Om det var det du menade? :q :)

------------------
SPiN, bjorne.w@telia.com

-- §e Grr... --

[Redigerat av SPiN den 25 apr 2001]

Medlem sedan juli 2000212 inlägg
#3

Jag har gjort ett template system för detta.

Det består av en class som man initierar med en array med taggar som skall byta ut i en fil.

Documentation:
Template class

PHP Syntax:
$template = new Template('temp_name',
à array('PROP_NAME1'=>'PROP_VAL1','ARG_PROP2'=>'PROP_VAL2', ...));
$template->Top();
...
$template->Bottom();
- Uses template files (*.tpl). Searches in the ‘template_dir’ directory defined in prepend.php.

Template Syntax:
<!-- top_start -->, <!-- top_end -->, <!-- bottom_start -->,
<!-- bottom_end -->
- These labels divide the template into two parts, top and bottom.

[NAME:default value]
- Some of the values/properties can be set by adding a array with property values as seen above. The properties must be defined in the template. The default value is only used if the property isn’t defined in the array.
- Note that the [] – syntax can cause problems with js-code.

Example:

my_layout.tpl:
<!-- top_start -->

<html>
<head>
<title>[TITLE]</title>
<head>
<body bgcolor=”[BGCOLOR:#999999]”>

<!-- top_end -->

<!-- bottom_start -->

</body>
</html>

<!-- bottom_end -->

index.php:
require('prepend.php');
Import('Template');

$layout = new Template('my_layout',array('TITLE'=>'Bosma
à Development'));

$layout->Top();

print('hello world');

$layout->Bottom();

Returns this to the user:
<html>
<head>
<title>Bosma Development</title>
<head>
<body bgcolor=”#999999”>
Hello world.
</body>
</html>

Om du är intresserad kan jag skicka över: kontakta niels_bosma@hotmail.com

IDEE: Vore det inte bra om man kunde skicka upp filer tillsammans med sina forum postningar som man kan göra på http://vb-world.net?

------------------
www.phpfunctions.com

130 ms totalt · 3 externa anrop · v20260731065814-full.b746b907
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
128 ms — hämta tråd, inlägg och bilagor (db)