Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#109 2016-08-21 16:57:48

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

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

4.6 beta 2

Just installed it and turned it on, but no Macros link appears under Content, as the instructions say.

Also, Stef, if you’re putting plugin code on GitHub these days, could you add your GitHub link to your website, or forum sig, pretty please? A few less steps to get there would be nice.

Offline

#110 2016-08-22 02:05:52

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Offline

#111 2016-09-13 21:20:24

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

Using Textpattern 4.6. I updated all my plugins to register tags using \Textpattern\Tag\Registry, but Debug mode still complains about the macro tag I created using this plugin. Is there a simple way to fix this?

Offline

#112 2016-09-13 22:49:10

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

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

johnstephens wrote #301431:

Debug mode still complains about the macro tag I created using this plugin. Is there a simple way to fix this?

Try the latest bleeding edge master branch. If you can put up with the UI being a bit out-of-whack for the time being, I’ve just added support for auto-registering macros under 4.6.0.

Please give it a whirl and let me know if there are any issues.


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

Offline

#113 2016-09-14 14:00:54

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

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

That solves it. Thank you, Stef!

Offline

#114 2016-12-21 14:09:34

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

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

Upgrade from Txp 4.5.7 to 4.6.2 locally … smd_macro v0.30
Doesn’t load macros … no errors or what so ever … !?
Both tested on server (MAMP) with PHP 5.6 and 7.x

Last edited by RedFox (2016-12-21 14:09:56)

Offline

#115 2016-12-21 15:16:48

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

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

RedFox wrote #303332:

Upgrade from Txp 4.5.7 to 4.6.2 locally … smd_macro v0.30
Doesn’t load macros … no errors or what so ever … !?

Weird. Even with your site set to Debugging mode? It works for me. That said, you could try smd_macro v0.40 and see if things improve.

When you say “doesn’t load” do you mean you can’t edit/import macros? Can’t see the admin interface at all? Or do they just not execute on the public site?


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

Offline

#116 2016-12-21 16:35:18

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

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

Yes, the UI is there, and I can edit but no macro shows up > screenshot
And there is a db table … and rows (macros). I will try v0.40 … thumbs up!

[edit]
Sorry, v0.40 didn’t help … :(

[edit]
Weird indeed … because the macros active on the site are working … !?

Last edited by RedFox (2016-12-21 16:44:08)

Offline

#117 2016-12-21 17:21:34

RedFox
Member
From: Netherlands
Registered: 2005-03-25
Posts: 805
Website

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

!!?? @Bloke … I just narrowed the browser window and did a hard refresh (not for the first time!) and guess what > screenshot … :))

Last edited by RedFox (2016-12-21 17:22:08)

Offline

#118 2017-01-20 11:05:29

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

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

Just thought I’d share this macro with everyone as it’s pretty handy.

Say you have an article and you want inline images. You use some plugin (e.g. smd_imagery) to attach a bunch of images to your article image. You want to drop them into your article — inline — in the order given in the article image field. This macro is the ticket.

So you make your article like this:

I'm a little teapot.

<txp:img />

Short and stout.

<txp:img />

Here's my handle.

<txp:img />

Here's my spout.

<txp:img />

If your article image field contained IDs 42, 17, 11, 85 then those images would be dropped into the article every time a <txp:img /> tag is encountered. If an image doesn’t exist, the macro (currently) outputs nothing at that place. You could get it to dump an error message in debug mode if you wish.

The macro maintains an image directory for each article so you can use them in a list context / landing page without the lists clashing. Of course you could extend the macro to display figure / figcaption / thumbnail or whatnot if you preferred; right now it just dumps the full-size image wherever the placeholder appears. Heck, you could even add an attribute to switch between behaviours so it might output a thumb or a full-size. But I kept it super simple for now.

The advantage to this is you’re not constrained by inserting complex image tags and IDs into your document body. Just sprinkle an identical ‘placeholder’ tag where you want an image to appear and manage the order and content of those images elsewhere in a separate field.

Here’s the macro. Just save the code below as img_macro.ini and import it into the plugin, then play:

[img]
description = "Insert images in sequence from the article_image field"
definition = "PHR4cDpwaHA+DQppZiAoIWZ1bmN0aW9uX2V4aXN0cygnc21kX2ltZ2luYycpKSB7DQovKioNCiAqIEluY3JlbWVudCBpbWFnZSBjb3VudGVyIHBlciBhcnRpY2xlLg0KICoNCiAqIEVhY2ggaW1hZ2UgaXMgaW5kZXhlZCBieSBpdHMgYXJ0aWNsZSB1cmwtdGl0bGUgc28gdGhlcmUncyBhbg0KICogaW5kZXBlbmRlbnQgY291bnRlciBwZXIgYXJ0aWNsZS4gVGhpcyBlbnN1cmVzIHRoYXQgYXJ0aWNsZXMNCiAqIGNhbiBiZSB1c2VkIGluIGEgbGlzdCBjb250ZXh0IHdpdGhvdXQgY2xhc2hlcy4NCiAqDQogKiBOb3RlIHRoaXMgbmVlZHMgdG8gYmUgYSBmdW5jdGlvbiBiZWNhdXNlIHRoZW4gdGhlIHN0YXRpYyB2YXJpYWJsZXMNCiAqIGhhdmUgbG9jYWwgc2NvcGUgYW5kICdzdGljaycgZWFjaCB0aW1lIGl0J3MgY2FsbGVkLiBUaGV5IGdldCByZXNldA0KICogaWYgaW4gdGhlIGdsb2JhbCBzY29wZS4NCiAqKi8NCmZ1bmN0aW9uIHNtZF9pbWdpbmMoKQ0Kew0KICAgc3RhdGljICRzbWRfaW1nID0gYX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vements or fixes, please post here.


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

Offline

#119 2017-01-20 20:49:45

giz
Member
From: New Zealand
Registered: 2004-07-26
Posts: 259
Website

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

Thanks, Bloke.

Very useful, and works a treat!

Offline

#120 2017-01-21 02:46:54

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,058
Website

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

Just a small quibble: it would be nice if you could publish an up-to-date version of this plugin. I don’t know if v0.30, linked from the first post in this thread works on TXP 4.6+

On my local playground install, I had smd_macro v0.20 installed (haven’t used the plugin for ages), so I went to github to check the latest shinny thing. There is 0.40 release tagged there. I downloaded, and tried to install that, only to run into a bazillion of errors (both TXP4.7-dev and 4.6.2). I was ready to file an issue when I noticed somehow that there some newer commits that actually would fix my issues. Used Plugin_composer (after deleting v0.40) and all is well.

Now I’ll go to play with that interesting macro you posted above. Wonder if I can get it to work with a custom field (as I already use <txp:article_image /> for different purposes) and <txp:images />.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

Board footer

Powered by FluxBB