SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict Php_penguin's Avatar
    Join Date
    Aug 2004
    Location
    Colwyn Bay, Wales, UK
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to implement "smart tags"

    For those of you have used ASP before now, you might have a better understanding of what i am trying to implement.

    Of course, seeing as i am posting in a PHP forum, seems like I shall have to explain.

    I am trying to build a templating system (similiar to the way Actinic does it), and one of the major things here is to allow users to type in "smart tags". For example, if I were to put in the following:
    Code:
    <MyTags:run function="drawMenu" />
    this would run a function whose output would replace that tag.

    other ways to achieve the same thing could be:
    Code:
    <MyTags:HTMLTemplate src="leftHandMenu" />
    But i digress.
    I was wondering which methods would be best to pick up where these tags are, and what the names and attributes of them are.

    Ideas i thought of so far:
    parse the code as a DOM:Element, and react to similiar tags
    another idea
    use preg_match_all() (?) with a fancy regex expression to grap anything starting with "<MyTags" until "/>".

    any ideas?

  2. #2
    SitePoint Addict Php_penguin's Avatar
    Join Date
    Aug 2004
    Location
    Colwyn Bay, Wales, UK
    Posts
    287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, i know, double post.

    here is my attempt at a regex:
    Code:
    ^/\b<MyTags:\b/i(?P<name>[A-Za-z0-9]) (?P<attrib>[A-Za-z]\=\"[A-Za-z]\") \b /> \b/i$
    no doubt that is wrong though..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •