Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-02-22 22:08:05

tkn
Member
From: New York
Registered: 2004-06-29
Posts: 39
Website

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

#2 2005-02-22 23:00:10

supa
Archived Plugin Author
Registered: 2005-02-10
Posts: 27
Website

Re: Need a powerful macro plugin

Isn’t that how the entire TXP plugin system works?

Offline

#3 2005-02-22 23:03:23

tkn
Member
From: New York
Registered: 2004-06-29
Posts: 39
Website

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

#4 2005-02-23 01:41:28

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

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

#5 2005-02-23 17:02:02

tkn
Member
From: New York
Registered: 2004-06-29
Posts: 39
Website

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

#6 2005-02-23 18:06:05

supa
Archived Plugin Author
Registered: 2005-02-10
Posts: 27
Website

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

#7 2005-02-23 19:36:36

supa
Archived Plugin Author
Registered: 2005-02-10
Posts: 27
Website

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

#8 2005-02-23 23:50:38

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: Need a powerful macro plugin

I’m glad someone is working on this, but I have a question. Where do i define the macros?

Offline

#9 2005-02-24 03:15:34

supa
Archived Plugin Author
Registered: 2005-02-10
Posts: 27
Website

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

#10 2005-02-25 02:55:41

soulship
Member
From: Always Sunny Charleston
Registered: 2004-04-30
Posts: 669
Website

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

#11 2005-02-25 03:49:10

swf
Plugin Author
From: Saskatoon, Saskatchewan Canada
Registered: 2004-06-21
Posts: 109
Website

Re: Need a powerful macro plugin

take you time, and eat your lunch. I can wait

I was jsut confused. I not even sure how to use a regex plugin (i just need a simple find and replace macro.

Offline

Board footer

Powered by FluxBB