Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Need a powerful macro plugin
One thing I really miss from MT is Brad Choate’s macro and regex plugins. It really allowed for some cool stuff. Is there an equivalent for Txp? I really would like to be able to build custom tags of my very own and do pattern matching for processing pages.
Offline
Re: Need a powerful macro plugin
Isn’t that how the entire TXP plugin system works?
Offline
Re: Need a powerful macro plugin
I am not really familiar with PHP, so I couldn’t really say… if that is the case, then I guess I will have to actually take a look at it…
Offline
Re: Need a powerful macro plugin
for now there is this hack but it would be nice if someone could figure out a way to integrate this as a plugin.
In a perfect world it would check a for a form that contains your list of macros. I’m sure I could work something out like this if I wasn’t so busy teaching a new semester of classes I’ve never taught before. Oh well there are a lot of smart people out there that could do it (hint hint)
Offline
Re: Need a powerful macro plugin
Yeah I would love to automate things like have address tags automatically linked to google maps, create my own easy amazon tags, regex search and reduce the size of caps and do some other typographic and useful automations….
Offline
Re: Need a powerful macro plugin
Hmm.. Something like this doesn’t seem too hard and I think it would be useful for some “advanced” TXP users out there.
Let me see what I can do.
-Steve
Offline
Re: Need a powerful macro plugin
Here’s something I hacked together while eating lunch:
http://www.bluecamel.org/software/textpattern/sab_regex.txt
Install it and let me know if you have any questions! There is no documentation, but something like this works:
<code>
<txp:sab_regexdefine search=”/test/”><img src=“http://www.google.com/images/firefox/title.gif” alt=”“ /></txp:sab_regexdefine>
<txp:sab_regex>
test post this is a test test
</txp:sab_regex>
</code>
You can define as many regex’s as you want and they will all be processed. However, you can specify a name and call out only that regex:
<code>
<txp:sab_regexdefine name=“testingmacro” search=”/test/”>
<img src=“http://www.google.com/images/firefox/title.gif” alt=”“ />
</txp:sab_regexdefine>
<txp:sab_regex regex=“testingmacro”>
test post this is a test test
</txp:sab_regex>
</code>
Be careful though, as something like this will output broken images:
<code>
<txp:sab_regexdefine search=”/test/”>
<img src=“http://www.google.com/images/firefox/title.gif” alt=”“ />
</txp:sab_regexdefine>
<txp:sab_regexdefine name=“blah” search=”/google/”>
yahoo
</txp:sab_regexdefine>
<txp:sab_regex>
test post this is a test test google
</txp:sab_regex>
</code>
Also at your disposal:
<code>
<txp:sab_regexifmatch pattern=”/regexpattern/”>
print this if it matches pattern
</txp:sab_regexifmatch>
</code>
<code>
<txp:sab_regexifmatch val=“test post” value=”<txp:title />”>
print this if “test post” matches the article title
</txp:sab_regexifmatch>
</code>
<code>
<txp:sab_regexifmatch name=“testingmacro”>
print this if it matches the “testingmacro” pattern defined above
</txp:sab_regexifmatch>
</code>
And lastly, theres <code><txp:sab_regexifnotmatch></txp:sab_regexifnotmatch></code> that does the exact opposite.
If there are any problems with this plugin let me know (I’m sure there will be!).
-Steve
Last edited by supa (2005-02-23 20:13:25)
Offline
Offline
Re: Need a powerful macro plugin
This isn’t the macro one, it’s the regex one. Gimme a break, it was a half hour’s worth of work!
I’ll finish up a macro one during tomorrow’s lunch ;) If you must have it now, you can probably get away with the same functionality using some clever regex-ing.
-Steve
Last edited by supa (2005-02-24 03:20:34)
Offline
Re: Need a powerful macro plugin
You gotta slow down steve, you’re gonna get carpel tunnel pumping out of your smokin finger if you keep cranking out txp hacks and plugins like this. It’s not human I tell ya!
;)
Jamie
Offline
Offline
Pages: 1