Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#61 2011-12-14 20:51:36

From: Gainesville, Florida
Registered: 2005-03-02
Posts: 786

Re: smd_macro: Create custom virtual Txp tags that do stuff

Good lord, I love this thing…

The one thing that is causing my forehead to go flat is the <p> tags issue. I’ve tried the rah_replace option, but can’t seem to get that to work. It seems to be closing the opening <p> of any paragraph I insert a macro in before the macro code, and then inserting an empty <p></p> at the end.

Can anyone verify rah_replace effectively removing the <p> tags?

Love shouldn’t be this frustrating. :)

Last edited by renobird (2011-12-14 20:52:46)


#62 2012-01-13 13:46:39

Plugin Author
From: Como
Registered: 2006-10-17
Posts: 248

Re: smd_macro: Create custom virtual Txp tags that do stuff


I have a problem with import/export.

I have exported a macro from my localhost website and I try to import it into my publish website but i get this text:
Macro file not in expected format

What is the problem?


#63 2012-02-19 23:57:34

From: Leeds, UK
Registered: 2006-01-29
Posts: 9,723

Re: smd_macro: Create custom virtual Txp tags that do stuff

v0.20 is out which sports:

  • (fanfare) Container macros — thanks to jakob for testing
  • Fixed UTF-8 collation and character set issues — thanks Uli / jakob
  • Forced lower case attribute names — thanks Uli
  • Fixed hyphen/underscore bug and sanitized tag attributes — thanks Uli

Hope the new container support allows you to do much more with your macros and virtual tags. The offer still stands if anybody comes up with some cool tags that might be useful to others, I’ll put them in the plugin help.

The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp


#64 2012-02-20 00:08:07

From: Germany
Registered: 2005-01-20
Posts: 3,937

Re: smd_macro: Create custom virtual Txp tags that do stuff

Macro file not in expected format

Marco, not sure if you still have the problem, but this happened to me today until I replaced /tmp with the whole path to the temp dir from root in the advanced prefs.

TXP Builders – finely-crafted code, design and txp


#65 2012-02-20 20:32:04

Plugin Author
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533

Re: smd_macro: Create custom virtual Txp tags that do stuff

Hi Stef,

This might interest you (or may not). That link links to one of my plugin’s issue tracker where Jools-r asked if I could add some extending functionality that other plugins, specifically smd_macro, could use. I did, and added hooking points for other plugins.

This secrecy. What is that plugin? Rah_flat, which allows editing “any” database table as flat files with the help of XML configuration files. What does that have do with you? Smd_macro. Static files. Those callbacks. Post-submit compiling ;-)

Huh what? Some as in here, or specifically as in case of smd_macro:

register_callback('smd_macro_pancake', 'rah_flat.importing');

function smd_macro_pancake($event='', $step='', $table='') {
	if($table != 'smd_macro')

		Gets the row currently being imported

	$data = rah_flat::row();

		Builds attribute, um, somehow, not sure... as JSON? I.e.
			<attributes>{ 'attribute' : 'value', 'attribute' : 'value' }</attributes>

	$data['attributes'] = json_decode($data['attributes']);

		Builds code.

	$data['code'] = smd_macro_build(

		Sanitize attributes

	$data['attributes'] = sanitize($data['attributes']);

		Give back in compiled row


Word flat makes me think pancakes (inner fatty). Just throwing all this madness out there. Or asking. Opinion. Directing people’s voice (does a person count as people?). Rah_flat itself is pretty complicated plugin (likely will never be even released as compiled plugin package as it requires advanced configuration, and is only meant for SVN/git/hg users). Dunno myself even, if smd_macro should take any action to support rah_flat. But yeah.

Last edited by Gocom (2012-02-20 20:38:14)


#66 2012-11-25 01:16:30

From: Portland
Registered: 2006-05-11
Posts: 373

Re: smd_macro: Create custom virtual Txp tags that do stuff

Just an idea Stef:

<squid:stuff type="things" amount="lots">
<squid:stuff type="non-things" amount="none" >

As if to suppose txp was not needed and squid, shark or any other thing would be fine.

I know the plugin uses <txp: as do txp tags. That makes sense of course.

I guess my question is, can this plugin be altered to down to the level of offering a “squid templating system”? I know that sounds silly but the case might be: User base have profiles which act as mini-sites. A set of tags named in the likeness of the squid name could be available to them as a means to do their own layouts and so forth. The vain pursuit of unified naming for a brand might benefit that brand from this type of detail. I know I’d try it.

Sorry if this is too far out there but it’s been scratching my noodle for a few days and I’m not ashamed to admit it.

An offshoot called smd_squid, if you like. :P

txtstrap (Textpattern + Twitter Bootstrap + etc…)


#67 2012-11-29 12:23:45

From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,460

Re: smd_macro: Create custom virtual Txp tags that do stuff

mrdale wrote:

I think we should have a designated place where we could all share useful and somewhat general macros.


This could easily be the wiki. (I put an empty page under the Community section of home page, if anyone wants to prime it.), but regardless of where it is, there should be a place. A new category in TXP Tips might also be a good place.

Right now I don’t think anyone is thinking of sharing macros because there’s no bazaar to do it.


#68 2012-11-30 01:12:32

From: Hong Kong
Registered: 2004-12-13
Posts: 2,395

Re: smd_macro: Create custom virtual Txp tags that do stuff

TXP Tips would be the right place. But without submissions I can’t do much. So if someone cares to send in their macro (or any other tutorials/tips) then I’d be happy to publish them and create new categories as needed.


#69 2012-11-30 20:22:38

From: Madrid, Spain
Registered: 2005-09-19
Posts: 389

Re: smd_macro: Create custom virtual Txp tags that do stuff

jstubbs dijo:

But without submissions I can’t do much.

Here goes mine, I used it on several sites succesfully:

<txp:photo>: a simple way to markup image layout within article body. The macro allows user to put images with 100% width, or X% width and aligned to left or right side. Optionally the user can ad a caption under the image.

How to use / Examples:

<txp:photo id="23" pos="left" caption="I am a photo aligned to left side"/>
<txp:photo id="23" pos="right" caption="I am a photo aligned to right side"/>
<txp:photo id="23" caption="I am a photo not aligned, I have 100% width"/>
<txp:photo id="23" />   <--(100% width and no caption)

Sample page using this macro: http://www.motorganga.com/classic-alforjas-y-bolsas-para-motos-custom
(the sample page use spanish words for the macro name, atributes and values son don’t search for “photo,left,right,caption” if you look at the page code. Also, the sample page use a bit more complex version of the macro, linking the images to another page: make your own superb photo macro version! )


  1. You need to install chh_if_data plugin to detect caption optional atribute.
  2. You need some CSS to layout the result properly (example CSS at the bottom).


Name Description Default value Replacement name
id id of the image. img_id
pos desired position (left,right) by default not aligned, 100% width. pos
caption (optional) show a text under the image. txt_caption

Macro definition:

<txp:variable name="caption" value="{txt_caption}"/>
<div class="photo {pos}"><txp:image id='{img_id}' width="0" height="0" />
   <txp:chh_if_data><span class="caption"><txp:variable name="caption"/></span></txp:chh_if_data>

Sample CSS (built your own version):

.photo {
width: 100%;
margin-bottom: 10px;}

.photo img{width:100%}

.photo.left {
float: left;
clear: left;
width: 30%;
margin: 0 3% 10px 0px;}

.photo.right {
float: right;
clear: right;
width: 30%;
margin: 0 0 10px 3%;}

.caption {
color: black;
display: block;
padding-top: 5px;
font-size: 9px;
font-weight: bold;
border-top: 1px dotted #E4E4E4;
line-height: 120%;}

{Edited to add some Textile. – Uli}

Last edited by milosevic (2012-12-03 06:39:53)



#70 2012-11-30 21:07:10

From: Cologne
Registered: 2006-08-15
Posts: 4,225

Re: smd_macro: Create custom virtual Txp tags that do stuff

Thank you for your example, Jorge!
(I’ve put some more Textile in your post, e.g. tables need a starting and ending pipe character per line. Is everything displayed as you intended?)

In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links


Board footer

Powered by FluxBB