I wrote a class that does exactly what you ask for my own cms. I downloaded src for you, since although I never released it, the source is released under a BSD style license. Custom tags
This basically allows you to do what you ask. There are some examples of custom tags in the class, so I will not embed code here. Let me know how you go.
Edit 1: Sample code as requested. :-)
Edit 2: I have to add that it supports hidden user tags.
Edit 3: It also supports built-in templating and tag replacement, i.e.
<ct:inline some="attribute"> This is an in line template. <br /> This is a
PHP / HTML: example.php
<?php $current_dir = dirname(__FILE__).DIRECTORY_SEPARATOR; require_once dirname($current_dir).DIRECTORY_SEPARATOR.'customtags.php'; $ct = new CustomTags(array( 'parse_on_shutdown' => true, 'tag_directory' => $current_dir.'tags'.DIRECTORY_SEPARATOR, 'sniff_for_buried_tags' => true )); ?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>untitled</title> <meta name="generator" content="TextMate http://macromates.com/"> <meta name="author" content="Oliver Lillie"> </head> <body> <ct:youtube id="wfI0Z6YJhL0" /> </body> </html>
Custom Tag PHP Function: tags / youtube / tag.php :
function ct_youtube($tag) { return '<object id="'.$tag['attributes']->id.'" value="http://www.youtube.com/v/'.$tag['attributes']->id.'" /><param ......>'; }
Output:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>untitled</title> <meta name="generator" content="TextMate http://macromates.com/"> <meta name="author" content="Oliver Lillie"> </head> <body> <object id="wfI0Z6YJhL0" value="http://www.youtube.com/v/wfI0Z6YJhL0" /><param ......> </body> </html>
buggedcom
source share