MTMacro
Sometimes it's nice to get a lot for a little. Macros let you do that. Instead of typing laborious HTML as you write your entries, a macro can do all the work for you so you can concentrate on writing. Perhaps you want to use a set of icons within your posts but don't care to write <img> tags all day long. Or maybe you'd like to link up to Google queries without having to type out the full URL. This plugin allows you to do that and much more.
Availability
You can download this plugin here: mtmacros-1_52.zip
Installation
To install, place the 'macros.pl' file in your Movable Type 'plugins' directory. The 'macros.pm' and 'postproc.pm' (the 'postproc.pm' file is only necessary for Movable Type 2.21) files should be placed in a 'bradchoate' subdirectory underneath your Movable Type 'extlib' directory. Your installation should look like this:
- (mt home)/plugins/macros.pl
- (mt home)/extlib/bradchoate/macros.pm
- (mt home)/extlib/bradchoate/postproc.pm
Refer to the Movable Type documentation for more information regarding plugins.
Description
This plugin allows you to define custom macros that can be expanded in a variety of ways.
Tags made available through this plugin:
- <MTMacroDefine>: Container tag used to declare a new macro.
- <MTMacroApply>: Container tag that applies existing macros against content.
- <MTMacroReset>: Resets the macro system, clearing all existing macros.
- <MTMacroContent>: Tag for accessing child data from container tag macros.
- <MTMacroTag>: Provides the tag being processed.
- <MTMacroAttr>: Tag for reading attributes from tag macros.
- <MTMacroMatch>: Tag for retrieving matched elements from a pattern-based macro or matched elements from a tag-based macro that uses a pattern for the tag name.
- <MTNull>: Container tag that literally does nothing.
<MTMacroDefine>
These attributes are allowed:
- name: Uniquely identifies a given macro. This attribute is required for the pattern and string macro types. If not specified for tag or ctag macros, the tag/ctag value will be used as the name.
- pattern: Used to define a pattern-based macro.
- tag: Used to define a tag-based macro (a tag with no closing element).
- ctag: Used to define a container tag-based macro.
- string: Used to define a simple search/replace macro.
- once: Only process macro against the first match.
- recurse: Evaluate the result of this macro for additional macros.
- no_html: Keeps macro from altering any content within HTML tags. Should not be used with tag and ctag macros since they would never match anything.
- no_case: If specified, string, tag and container tags are mtached without respect to case.
- script: Causes the Macro to be evaluated as an executable script. The value of this attribute should be a defined scripting language that is known to the Macros plugin.
Note: You can only specify one of the following attributes: pattern, tag, ctag, string.
Note: tags specified with the 'tag' and 'ctag' attributes can contain pattern matching elements.
Note: Macros are processed in the order they have been defined.
Here's an example:
<MTMacroDefine name="smiley1" string=":^)">
<img src="/images/smiley1.gif"
height="20" width="20"
alt=":^)" />
</MTMacroDefine>
There's a simple search/replace macro that changes all the ':^)' to an IMG tag that points to (hopefully) a smiley graphic.
Here's a pattern-based macro:
<MTMacroDefine name="uppercase" pattern="m/\^\^(.+?)\^\^/"> <MTNull upper_case="1"><MTMacroMatch position="1"></MTNull> </MTMacroDefine>
Here's a tag macro:
<MTMacroDefine tag="line"> <hr noshade="noshade" width="<MTMacroAttr name="width" default="100%">" /> </MTMacroDefine>
Finally, a container tag macro:
<MTMacroDefine name="blue" ctag="blue"> <span style="color: blue"><MTMacroContent></span> </MTMacroDefine>
Tag macros can use patterns too:
<MTMacroDefine name="smileys" tag="smiley(\d+)"> <img src="/images/smiley<MTMacroMatch position="1">" height="20" width="20" alt=":-)" /> </MTMacroDefine>
Your macros can be as complex as you'd like. Here's a fancy one I put together that invokes the MTAmazon plugin whenever you use a custom 'amazon' tag in your blog entries:
If you can follow that, you'll begin to see the power of this plugin. Here's a before/after view what it does:
And when you publish, it comes out like this (the purple popup there is done using the Overlib script):

<MTMacroApply>
This container tag applies macro rules to anything contained within it.
These attributes are available:
- macro: Assign '1' to cause all defined macros to expand. Or you can provide a list of space-delimited macro names. Or you can specify a regular expression matching pattern in the form of "m/pattern/" to have it select macros by a pattern.
- recurse: Instructs macro expansion to continue to evaluate macro results.
Here's how you might use it:
<MTMacroApply> <MTEntryBody> </MTMacroApply>
Or perhaps you only want to apply certain macros. This will only apply the macros named 'bold' and 'italic':
<MTMacroApply macro="bold italic"> <MTEntryBody> </MTMacroApply>
A pattern can also be used to select macros. This applies any macros that are named with 'body_' as a prefix:
<MTMacroApply macro="m/^body_/"> <MTEntryBody> </MTMacroApply>
Another way to invoke the macros is to use the 'apply_macros' global tag attribute. This allows you to apply macros to any 'MT' tag.
<MTEntryBody apply_macros="1">
Or apply selectively, with a list of macro names or a pattern:
<MTEntryBody apply_macros="m/^body_/">
<MTMacroReset>
Use this tag to clear all defined macros.
<MTMacroContent>
When used in side a macro definition, this tag expands to the value of the content contained within the container macro tag currently being processed.
These attributes are available:
- default: Allows you to specify a default value in the event that there wasn't any content in the macro tag. Supports embedded expressions.
<MTMacroTag>
Returns the name of the tag currently being processed.
These attributes are available:
- rebuild: If specified, MTMacroTag will return the full opening tag for the tag being processed. It will add all existing attributes.
- quote: Used to specify the quote character for rebuilding the tag expression (defaults to ").
<MTMacroAttr>
This tag is used with tag or container tag macros. You can use it to select the values of attributes used in your tag.
These attributes are available:
- name: The name of the attribute you are fetching.
- value: A value to assign to the existing tag. Useful in conjunction with the 'rebuild' attribute of the MacroTag tag. Supports embedded expressions.
- remove: If specified, the named attribute will be removed from the list of tag attributes.
- default: A default value to assign in case the attribute was unspecified (note: blanks are considered values-- the attribute must not be present at all in order for a default value to be assigned). Supports embedded expressions.
<MTMacroMatch>
This tag is used to select matched elements of a pattern-based macro or parts matched from a tag-based macro.
These attributes are available:
- position: The matched element you want to extract.
- default: The default value to assign in case the matched value is empty. Supports embedded expressions.
<MTNull>
This tag is used to invoke the global tag attributes, like 'upper_case'. It doesn't do anything to the contained content other than processing it normally.
Usage Notes
- For any tag attribute above that mentions 'supports embedded expressions', that means that the attribute can contain a Movable Type expression in the form of "[MTEntryTitle]" or "<MTEntryTitle>". If the attribute contains such content, it will be evaluated.
- If you use the pattern matching macros or you use a pattern to define your tag macros,
please form them carefully or your macro may match more than you expect. For a tutorial on using Perl regular expressions
visit this page: http://www.perldoc.com/perl5.6.1/pod/perlretut.html
And for advanced documentation, look here: http://www.perldoc.com/perl5.6.1/pod/perlre.html - The 'script' attribute of the MTMacroDefine tag is extensible. Refer to my "PerlScript" plugin as an example of how to provide scripting support to this plugin.
Support
If you have any questions or need assistance with this plugin, please write your comments, complaints, suggestions, criticisms here: http://www.bradchoate.com/past/mtmacros.php
License
Released under the MIT License.
Changelog
- 1.52: string and pattern attribute values of the MTMacroDefine tag are now decoded for HTML entities.
- 1.51: Bugfix for 'script' attribute when nested MT tags are present.
- 1.5: Added 'script' attribute to MTMacroDefine.
- 1.4: Added 'no_case' attribute to MTMacroDefine.
- 1.31: Corrected closure tags for embedded expressions.
- 1.3: Added 'no_html' attribute to MTMacroDefine.
- 1.2: Added 'recurse' and 'once' attributes to MTMacroDefine. Added 'recurse' to MTMacroApply. Fixed bug where container tag 'MyTag' matches tag 'MyTagSomething' (due to similar name prefix).
- 1.1: Added 'value' and 'remove' to MTMacroAttr. Added 'rebuild' to MTMacroTag.
- 1.0: Initial release
Hi Brad
This may be a stoopid question, but where does one find the postproc.pm? It wasn't in the zip file and I've had a breif look at some of the other plugins you've made but can't seem to find it.
Or am I doing something obviously wrong?
Brad
http://rat-bag.net/blog
Cancel that...I'm just thick...found it :-)
Sorry-- the 'postproc' plugin (actually not a full plugin since it really doesn't do anything on it's own) was supposed to be in the distribution. I've updated the zip file to include it. You can find the postproc plugin separately within my 'Movable Type' category archive (click the 'Movable Type Tips' link at the top of the page to jump over to it).
Thanks Brad,
By the way, I posted a message at the MT Support forums, I'd like you to have a squiz at when you have a moment (don't want to double up and post it here too)
http://www.movabletype.org/cgi-bin/ikonboard/ikonboard.cgi?s=3d589e3b60ffffff;act=ST;f=20;t=6690;st=0
Brad
this may be another stoopid question, but doesn't hooking Amazon into MT force you into the commercial for-profit clause of the MT license? Doesn't the MT license say something to the effect "if you make money off it, you have to pay the commercial license"...
Excellent question. Since my site uses it too, I asked Mena about this specifically. She said no-- a personal site using associate links to Amazon would not require a commercial Movable Type license-- unless you're "making $1000 a month" or something. I replied, "yeah right-- if that happens, I'll split it 50/50 with you!". Hopefully they'll clarify this point in their FAQ or license agreement.
I've almost finished implementing the MTMacro plugin to check for when MTAmazon returns no results.
I'm trying to search for the term:
<div class="buy"></div>
and replace it with the sting
<div class="buy">Not found at Amazon..</div>
I can't figure out how to format the string attribute of MTMacroDefine to transform the <, >, and the " characters.
Any ideas? I'm so close to launch..
AHHHHHHHHHHHHHHHHHHHHHHHH!
I've been working with this macro for about 3 hours now, and can NOT get the #### thing to work. I'm sure it's probably something stupid i did.
Here's what i decided to test:
[img]/images/smiley1.gif[/img]
I PLACED the code about right after my first body tag in index.html template
Then around the code in index.html template that renders the weblog entries i placed
SO i have like this:
*BODY
[img]/images/smiley1.gif[/img]
*WEBLOG ENTRY CODE
The only thing that happens is up to where mtmacrodefine is, a smiley loads. What the #### am I doing wrong? I read over the documents over and over, but i can't find a example of where to put the code. :(
The MacroDefine tags can be placed anywhere you'd like in your template, as long as it is ABOVE the MacroApply tag. Tags are processed in order, so if you use the apply tag before the macros are defined, it won't do anything...
It sounds as if you either haven't installed the plugin right or you're not using Movable Type 2.21. And I hope that instead of [img], you're really writing <img src="/images/smiley1.gif" /> or something to that effect...
Also, you may have just had a typo, but you close the <MTMacroApply> with </MTMacroApply>...
Brad
That works beautifully! Impressive programming.
I used your macro locallink/offsitelink and seen how DiveIntoMark even put an IMG inside.
But I cannot figure out myself following (even more difficult) macro.
My outside links are counted by countlink.cgi which resides on my domain:
http://www.groovycompany.nl/linktnaar/countlink.cgi?www.bradchoate.com/
Could I auto-macro-cally replace the normal http://outside-> link with http://countlink.cgi?outside->
And can this Macrocontent change be done with the same macro changing the style of the ctags?
Hope I made this question clear, maybe you can point me in the right direction?
Thanks and have a nice weekend!
Lawrence
This should do it-- basically this will rewrite the href attribute, tacking on your CGI to the front. The original URL is added to the end and URL encoded. Your CGI will need to URL decode the link and add the 'http://' back to the URL:
<MTMacroDefine name="links" ctag="a"> <MTIfMatches expr="[MTMacroAttr name='href']" pattern="m/.+/"> <MTMacroAttr name="class" value="local"> </MTIfMatches> <MTIfMatches expr="[MTMacroAttr name='href']" pattern="m|^http://(?!.*groovycompany\.nl.*)|"> <MTMacroAttr name="class" value="offsite"> <MTMacroAttr name="href" value="http://www.groovycompany.nl/linktnaar/countlink.cgi?[MTMacroAttr name='href' regex='s!^http:!!' encode_url='1']"> </MTIfMatches> <MTMacroTag rebuild="1"> <MTIfMatches expr="[MTMacroAttr name='class']" value="offsite"><img alt="[offsite]" title="" src="/images/offsite.gif" width="11" height="11" /> </MTIfMatches> <MTMacroContent> </a> </MTMacroDefine>
Collapse that all back to one line to avoid extra spaces in the resulting HTML.
Thanks Brad,
You helped a lot and I got it working perfectly. For anyone who would like to see the final working macro I made a partly english post about it on my Blog: http://www.groovycompany.nl/Blog/Archives/000139.php#more
This is just a stupidly silly question, I'm sure the answer is staring me in the face and I'm pretty embarassed to even have to ask it - where exactly do you create the macros?! Is there a form filled in that takes care of it all, do you put all the code in a seperate file and include that, or stick it between the head tags?! I've not been blessed with a particularly technological (or sensical) mind, help!
*sigh* I'm having some difficulty getting MTMacros to work. I'm using MT 2.21 with apache-1.3.23-14, perl-5.6.1-34.99.6, and mod_perl-1.26-5 on RedHat 7.3. I've got MT running with mod_perl, FWIW.
The problem I'm having is that MTMacros seems to die when processing the macro definitions. If I define a macro as
<MTMacroDefine name="test" string="foo">bar baz bap</MTMacroDefine>
directly in the template, when the template is rendered, I end up with
bar baz bap</MTMacroDefine>
It looks like something's dying when processing the tag. Can someone help?
With mod_perl, you have to specifically add the 'mt/extlib' directory to Perl's include path. The way I did it on my server is to add a line like this:
PerlRequire /path/to/startup.pl
in the httpd.conf file. That Perl script includes a line like this:
use lib qw(/path/to/mt/extlib /path/to/mt/lib);
With that in place, the required files under the 'extlib' directory should be visible to mod_perl.
Well, I'm with Tina above...can't quite make head or tails with this one. I'm sure (eventually) I can figure out how to create my own macros, but just using Mark's (http://diveintomark.org/inc/macros) for now, I still can't even get that far!
Uploaded install files as said, created a "bradchoate" sub-directory within /extlib/, and even 755'ed the "macros.pl" file for good measure though it isn't specified I need to do that (didn't mess with chmod permissions on the other two files).
Took Mark's complete macros file and created a template module with it, and then referenced that module with the tag from Mark's post (http://diveintomark.org/archives/2002/08/15.html#better_living_through_regular_expressions)
at the top of my index.html and individual entry templates. rebuilt (fine). then created test post with a bunch of acronyms, published, but no acronym tool tips on live (test) site.
From a thread at MT's Support Forum, there's an implication that I need to specify a path in my mt.cfg file, but I looked at that file and there doesn't seem to be any obvious place (like "plugins") where I would do so.
Well, it never fails, 5 minutes after you hit the Post button, you figure it out....I did't see that bit about the ApplyMacro tag....works fine. Now, if I can only wade through the rest of the gobbledygook upstairs and write some of my own...I mean Mark's acronyms are great, but I don't find myself typing API very often...
I posted this over at the forum but thought I'd add it here as well (with less description). I'm getting this error message:
Can't declare undef operator in my at extlib/bradchoate/macros.pm line 34, near ") ="
Boohoo!!
Hello,
I was able to successfully install and run MT, but I can't make this plug-in work. My new installation had no "plugins" or "extlib" directory, so I made them, and put the files in the proper places. I did a very simple search/replace macro, but it doesn't work.
I'm sure the problem is that I'm missing a newbie step, but it feels like the instructions may be missing something.
-- Charles Wiltgen
This is weird: Can anyone tell me why this macro won't compile -- the error I get is that
MT::App::CMS=HASH(0x8066e58) Argument "[MTMacroAttr name='lastn' default='3']" isn't numeric
which means it doesn't expand that one MTMacroAttr call ... but why doesn't it?
here's the macro:
<MTMacroDefine name="amazicon" tag="amazicon">
<table cellspacing="0" cellpadding="4">
<MTAmazon search="[MTMacroAttr name='search']" method="[MTMacroAttr name='method' default='Keyword']" line="[MTMacroAttr name='line' default='books']" lastn="[MTMacroAttr name='lastn' default='3']">
<tr><th><a href="<MTAmazonLink>" title="Buy it: <MTAmazonSalePrice>!" ><img src=\'<MTAmazonSmallImage>\' border=\'0\' hspace=\'5\' /></th><td align='top'><b><MTAmazonTitle></b><br />
<a href="<MTAmazonLink>" title="Buy it: <MTAmazonSalePrice>!" ><MTAmazonTitle>"></a><br/>
</td></tr>
</MTAmazon>
</table>
</MTMacroDefine>
further to my last post ... I removed those backslashes, but it still will not resolve those [MTMacroAttr name='search'] strings; they are passed to the amazon plugin verbatim. What did I forget?
In general, you won't be able to use expressions or MT tags in tag attributes. Some plugins can handle attribute values of [MTTagName] because they were written to convert those values to the actual content before the plugin does it's stuff.
This techinique first appeared in MTAmazon thanks to an idea and some sample code from Brad. MTAmazon was designed to allow MT expressions like [MTTagName] in the search attribute, but it doesn't support them as values for any other attribute.
The plugin is actually not expanding any of the macros in the attributes (except for in "search"). The reason you get an error on the lastn attribute but don't get one on the others is that lastn requires the value be a number. The other attributes don't, so when they get [MTMacroAttr ...] as a value, they accept it and move on. The lastn attribute sees that and dies because it's not a number.
If you were to remove the lastn attribute from the template, you'd stop getting the errors, but you'd never get any content back from Amazon. That's because they wouldn't understand a search method [MTMacroAttr name='method' default='Keyword'].
This whole thing has gotten me thinking, though. All my plugins should support MT tags as values to all attributes.
The next version of MTAmazon is under development to support the new releases of MT 2.5 and Amazon Web services 2.0. I'll make sure that it also allows all attributes to contain MT tags.
Hi, Brad. First, thanks for all the great contributions. I've just dug into MTMacros, following Mark Pilgrim's lead on using it to create hovers for acronyms. I've run into a challenge I can't seem to lick. That is, how to deal with acronyms that appear within an HREF. If I use the 'no_html' attribute, then I'll disable the intended affect. However, on the rare occasion that a URL contains a string that matches one of my acronymns, it corrupts the URL.
For example, having defined MTMacroDefine's to cover "IP" and "DMCA," the following URL gets fudged:
http://www.eff.org/IP/DMCA/20021003_eff_pr.html
Any suggestions?
Thanks.
Shawn: But that was the very reason why I added the 'no_html' option. Have you tried it? It will prevent string and pattern macros from altering any HTML tags (and their attributes naturally), like the 'A' tag.
Thanks for the reply, Brad. I misunderstood and thought it would prevent alteration of text BETWEEN tags, not within tags. I'll go back again.
Hi, Brad. Per the examples given by Mark Pilgrim, I'm using MTMacros and MTRegex to do acronym hover-over expansion. I'm using MTInclude's at the very top of each of my templates. The question is this: I now end up with a number of blank lines in the resulting HTML -- I assume after the macros have been processed. It's cosmestic only and not, of course, a functional problem. But I'm wondering if there's a switch or other method to have these blank lines "consumed" rather than left in the final HTML.
You could look at the source of http://algorhythm.org/ as an example.
Thanks
That's easy-- just delete any new-line or space characters inbetween Movable Type tags. If you do that, that should remove any empty lines you're seeing.
What a nice macro, and how bad I got no idea of how patterns work. Is it possible to write a rule that
- replaces ampersands in URLs only with &
or that
- replaces all ampersands with & but does not convert the ampersand in > ?
Your (or another readers) help would be so much appreciated.
I'm having a bit of a problem with a pattern in MTMacros. Its documented at http://www.movabletype.org/cgi-bin/ikonboard/ikonboard.cgi?s=3e10b1ee5f2affff;act=ST;f=20;t=12213
I'd appreciate it if you could take a look when you get a chance.
Thanks
Brad
Thanks for looking at my problem. the major issue turned out to be ... d'oh ... I thought that I had put a MTInclude tag in my Index ... but I hadn't. Everything is working fine now.
Hi Brad - thank you for your excellent plugins. I am using MTAmazon, and it is working because I can get the wishlist to work. However, your complex amazon search macro with overLIB showing the picture, is not. When I rebuild, I get -
MT::App::CMS=HASH(0x8331398) Use of uninitialized value in length at /virtual/rcogley/public_html/mt/extlib/bradchoate/macros.pm line 79.
MT::App::CMS=HASH(0x8331398) Use of uninitialized value in pattern match (m//) at /virtual/rcogley/public_html/mt/extlib/bradchoate/macros.pm line 81.
Could you possibly give me an idea of where to start looking?
Thank you in advance.
Kind regards
Rick
By the way, I am calling a template module with the macros in it, and that is where I pasted the long code example you have above, replacing the developer id and associate id.
Here is the URL of the template I am calling.
http://www.cogley.info/mt/tmpl/rc-macros.tmpl
It is working for the acronym expansion, fwiw.
Is there a rule as to where to put the code?
Kind regards, and your help is much appreciated.
RIck
Thank you Brad for your mail about replacing the double-byte chars with ' marks. THat did the trick on the rebuild errors. Duh. I wondered what the funny marks in the macro were...
However, even with the overlib script added at the top of the main index template, I cannot seem to get your amazon macro to work, trying the "tangerine dream" example. What I am seeing is -
Im also interested in .
... with a blank where the overlib hyperlink text should be.
Would you kindly take a look at this, on http://rick.cogley.info/eblog ?
Thanks so much.
Kind regards
Rick
Thank you Brad for your mail about replacing the double-byte chars with ' marks. THat did the trick on the rebuild errors. Duh. I wondered what the funny marks in the macro were...
However, even with the overlib script added at the top of the main index template, I cannot seem to get your amazon macro to work, trying the "tangerine dream" example. What I am seeing is -
Im also interested in .
... with a blank where the overlib hyperlink text should be.
Would you kindly take a look at this, on http://rick.cogley.info/eblog ?
Thanks so much.
Kind regards
Rick
Hi Brad,
I'm having the same problem Court Kizer was having back in August. Smilies visible at the MTMacroDefine...
I think I have all my paths setup OK and no spelling errors.
Any suggestions?
Brad -
As a follow on to this, I discovered some interesting things. Perhaps it would help others, so I will post here.
>> I still have the trouble with your demo macro, though, and I'd really appreciate your help on that.
I'm using the latest versions of MT and MTAmazon, but I was having a problem getting any MTAmazon template code to come up in posts. The MTAmazon code was working on the sides of the blog, but not in the posts.
On the MT forum, I found out I needed processtags and mtpostproc to fix this problem of in-post tags not working. So, I found them and did the installs.
However, when I ftp'ed processtags.pl to the plugins directory, and chmod'ed it to 755, right afterwards I uploaded my index template with the process_tags="1" added to the MTEntryBody tag. Then when I rebuilt the site, the rebuild process hung, and I got a 500 error when loading mt.cgi.
I decided to reverse what I had just done, and sure enough, when I delete processtags.pl, mt.cgi loads just fine.
After some more sleuthing, somewhere on the MT forum, someone mentioned adding this -
# use bradchoate::postproc;
if (MT->VERSION =~ m/^2\.2/) {
require bradchoate::postproc;
}
to processtags.pl, and it seems to have solved the problem of mt.cgi hanging. Now I can see the results from the MTAmazon tags in my posts.
However, I don't really understand why it worked. Can you perhaps explain? Maybe it's not really fixed or maybe it's something that will help you add code that will fix this problem I seem to have stumbled on.
Thanks and kind regards,
Rick Cogley
rick.cogley@esolia.co.jp
Brad,
I seem to have fixed my problem of MTAmazon not displaying tags, but I still have problems with your macro not working.
The way I fixed the MTAmazon in-post tags problem, was to add processtags.pl. However, it caused mt.cgi to crash, and after some searching, somewhere on the MT forum, someone mentioned adding this -
# use bradchoate::postproc;
if (MT->VERSION =~ m/^2\.2/) {
require bradchoate::postproc;
}
to processtags.pl, and this seems to have solved the problem. Now I can see the results from the MTAmazon tags in my posts.
However, I don't really understand why it worked. Can you possibly explain? Maybe it's not really fixed.
Kind regards
Rick Cogley
rick.cogley@esolia.co.jp
I installed the MTMacro plugin in my template and it works like a dream, my plan was to use the implementation to automate the entry of text for the Geourl plugin for MT. Unfortunately both plugins run when the entry is rebuilt and it seems that the geourl plugin is dependent on text being in the post prior to the rebuild. My implementation plan was to use the macro plugin to add the [[[lat]]] [[[long]]] text based on my location at the time of the post and have the geoulr plugin read that data. The dependency has got me stumped. Anyone have any ideas? Details about the Geourl plugin can be found at geourl.org
I installed MTMacros and set it up to handle emoticons/smilies... and get this error:
"Building entry 'something' failed: Build error in template 'Individual Entry Archive': Error in tag: You did not specify the type of macro."
What am I doing wrong?? Do I have to specify a macro type in some way not covered in your documentation?? I've put all the macro definitions in a module, called Emoticons, and call it with the tag in my templates. Each macro definition looks like this:
Help!!
Thanks,
Alyssa
Eek... the code didn't show up... I'll try again:
In the error, I'm getting an error in the tag:
I'm calling the Emoticons module with this tag:
Each macro definition looks like this:
Okay, I can't get it to show up... but I'd be incredibly grateful if you could email me or something and help me get this fixed!! Thanks!
Helpage!
I toss
height="12" width="12"
alt="red_mana" />
into my index php.
and in a blog i put !R
... and it doesnt replace.
I used the Amazon script that was recommended and it still didnt replace.
Where are we to put the macro tags?
Gah, it was macroapply
Next question, I get
"Build error in template 'Main Index': Error in tag: Error in tag: Error building macro tag amazon: Error in tag: You used without a search string.
"
when using your sample amazon script (with my affil code and dev code) and the sample html included... any idea why?
Im also interested in (open)amazon keyword=tangerine dream(close)some TD music(open)/amazon(close) results in
Build error in template 'Main Index': Error in tag: Error in tag: Error building macro tag amazon: Error in tag: You used without a search string.
followed by a string of
MT::App::CMS=HASH(0x173dda0) Use of uninitialized value in substitution (s///) at c:\inetpub\wwwroot\domains\GROUPN~1\users\rizwank\PUBLIC~1\GEEKYM~1\blogcgi\extlib/bradchoate/macros.pm line 116.
Help please!
Rizwan,
I too am getting that error. I stripped down the code and made it work without the "overlib" references.
" title="Buy now at amazon.com-- only !" " align="left" border="0" hspace="5" />
Amazon Price: ">
" title="Buy now at amazon.com-- only !" " align="left" border="0" hspace="5" />
Amazon Price: ">
You might give that a try, but I'd like it to work the way Brad has it on his documentation page.
Whoops, NM.
Brad filters out the "code" html tags so you cant see all the code.
Email me and I'll help you out with that.
Hi!
I'm trying for quite some time now to change the img-tags in my archivefiles into url-tags (to cut back on traffic).
See here for an example: http://cooliosbabes.flabber.nl/templates/example.txt
I can't seem te get the right expression to use for MTMacroDefine.
Can somebody please help me?
I've been pulling my hair out the last couple of hours trying to get this to work for the sample Amazon macro (which I modified for my devtoken and associate id of course). I kept getting an error when rebuilding, related to my amazon macro.
I finally tracked it down to the MTIfNotEmpty tag. You must have the IfEmpty plugin installed to use these tags.
Whoa. I got this working in like five minutes, including the time to scp the zipfile to my hosting provider. Seriously, this is beautiful, exactly what I was looking for.
Rizwan, I got one of those errors with my first attempt at expanding a macro and I traced it back to the regex I'd supplied -- I had a typo and also forgot the trailing / mark. Maybe you did something similar?
cheers,
--sabrina :)
I've installed MTAmazon and MTMacros successfully, but I'm having a problem with the Amazon macro. Some of the results returned have apostrophes, which causes overlib to choke. Any ideas on how to fix this would be welcome.
Thanks for the great plugins! When it does work the results look great!
HiBC,
I need yr help. Its very simple.. I can't seem to make ne of the plugins work. The HTML output just shows a last half of the Tag
Eg
Adding this on the template
and
On rebuilding the file the html source shows
I am using W2k, Apache 1.3.26, Perl 5.006, Mod_perl 1.25
I posted on MT Forums here
http://www.movabletype.org/support/index.php?act=ST&f=10&t=21068&s=49b5b8453bbd0c63186595323a5e1b96
but haven't found ne volunteer yet. Kindly help.
I tried the Mod perl tip u mentioned above bu it too is giving errors
===
[Tue Jun 03 01:10:24 2003] [error] c:\mt-modperl.pl did not return a true v
at (eval 4) line 1.
Syntax error on line 1070 of /usr/conf/httpd-php423.conf:
c:\mt-modperl.pl did not return a true value at (eval 4) line 1.
Note the errors or messages above, and press the key to exit. 26...
===
I tried changing every type of paths both relative and other... but always see this eror on starting Apache
Adding this on the template
[BracketsS]MTMacroDefine name="smile" string=":)"[BracketsC] [BracketsS]img src="smile.gif" alt="smile"[BracketsC] [BracketsS]/MTMacroDefine[BracketsC]
and
[BracketsS]$MTEntryBody apply_macros="1"$[BracketsC]
On rebuilding the file the html source shows
[BracketsS]img src="smile.gif" alt="smile"[BracketsC] [BracketsS]/MTMacroDefine[BracketsC]
One thing I noticed with you amazon example is that if I want to collect links via the Collect plugin, those that are created by the Macro are not collected, any thoughts on why...
Hi Brad! I've utilized several of your plugins on my site and they work like a charm! My fav is the MT Macro one, which allows me to autolink/auto tag frequently used text and images.
I've implemented MTAmazon in a sideblog using the overlib javascript as well -- and it works great. (see http://www.silverberry.org) However, I'm trying to implement the Amazon linking you've described in this post on MT Macro and cannot get it to work. I've created a blog for testing purposes -- and here's what I'm ending up with. I'm not quite sure what the problem is. I have the apply macros and process tags within the MTEntry Body tag -- but it still won't process it into the overlib. I've worked on it for several days now and can't seem to make any progress. Any thoughts??
You can see the test site for this code at http://www.silverberry.org/StaticPages/amazonmacro.php
Hi Brad! I've utilized several of your plugins on my site and they work like a charm! My fav is the MT Macro one, which allows me to autolink/auto tag frequently used text and images.
I've implemented MTAmazon in a sideblog using the overlib javascript as well -- and it works great. (see http://www.silverberry.org) However, I'm trying to implement the Amazon linking you've described in this post on MT Macro and cannot get it to work. I've created a blog for testing purposes -- and here's what I'm ending up with. I'm not quite sure what the problem is. I have the apply macros and process tags within the MTEntry Body tag -- but it still won't process it into the overlib. I've worked on it for several days now and can't seem to make any progress. Any thoughts??
You can see the test site for this code at http://www.silverberry.org/StaticPages/amazonmacro.php
Hi, I'm trying to get the Macro to work with smilies, and I'm really struggling. I keep getting this error:
Building entry 'BLANK' failed: Build error in template 'Individual Entry Archive': Error in tag: You did not specify a name for your macro.
I'm not sure what the "You did not specify a name for your macro." means. Any help would be much appreciated.
I am trying to implement this for the MTAmazon functunality. It is working...kind of.
It only searches books. I put in type="dvd" and it still only searches books.
Any idea what I am doing wrong.
Scratch that...five minutes after I posted I found the problem.
Now I have another issue. Since adding this in I am getting funky characters on my entries
(example) Read More » (/example)
Any ideas?