The idea of this Macro is letting you write a relative path for images and documents instead of the absolute one:
so:
Advantages:
Save the following code in imgdoc.php in you personal template directory
<?php
function view_macro_img($text)
{
$ImgDir = './img';
return '<img src=' . $ImgDir . $text . ' />';
}
function view_macro_doc($text)
{
$DocDir = 'doc/';
return '<a href=' . $DocDir . $text . '>' . $text . '</a>';
}
?>
Edit the file lib/defaults.php and add the following lines to the $ViewMacroEngine array
'img' => 'view_macro_img', 'doc' => 'view_macro_doc'
Add your file to parse/macros.php:
require('nkoniTemplate/imgdoc.php');
Thats'it!
MassimoI - massimoi@email.it
Use the following functions and you get new advanced features
Notice: you can use even full http:// type reference too...
function view_macro_img($text)
{
list($url,$width,$height) = explode(" ",$text,3);
$res = "<img src=\"" . $url . "\" ";
if ($width != "") {
$res = $res . "width=\"" . $width . "\" ";
}
if ($height != "") {
$res = $res . "height=\"" . $height . "\" ";
}
$res = $res . "/>";
return $res;
}
function view_macro_doc($text)
{
list($url,$label) = explode(" ",$text,2);
if($label=="") {
return "<a href=\"" . $url . "\">" . $url . "</a>";
}
return "<a href=\"" . $url . "\">" . $label . "</a>";
}
Have fun!
bartusl (bartus at alpha.tmit.bme.hu)