Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2011-05-09 06:50:44

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

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

Cool! and cunning. That works!

BTW: for those, like me, who may not initially understand the logic, it is ESSENTIAL to insert SMD_NONE (or a non-word of your choice) as the default value in the attributes section above the code:

That gives you a tag that behaves as follows:

  • <txp:figure id=123" caption="My custom caption" /> – inserts image 123 with an HTML5 figcaption entitled “My custom caption”.
  • <txp:figure id=123" /> – inserts image 123 with an HTML5 figcaption with whatever is set in your images caption field.
  • <txp:figure id=123" caption="" /> – inserts image 123 with an HTML5 figure and no figcaption.

Last edited by jakob (2011-05-09 06:55:11)


TXP Builders – finely-crafted code, design and txp

Offline

#50 2011-09-05 14:25:14

stephan
Plugin Author
From: Bochum, Germany
Registered: 2004-07-26
Posts: 196
Website

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

Tried it, loved it. But one thing I really need your help with:
I have a macro with several attributes and I do not wish to type the entire thing in each time. How can I integrate the marco in the write tab (e.g. insert the specific macro at the push of a button so all I would have to do is fill in the values of the attributes)?

The idea is to create a review rating table with a star rating via macro and the individual ratings in five categories would be the attributes (as the name of the object under review).


Yoko for Textpattern – A free blog themeMinimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often

Offline

#51 2011-09-05 14:36:04

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

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

stephan wrote:

I do not wish to type the entire thing in each time

I think this was covered earlier in the thread. Although it seemed that masa couldn’t get upm_quicktags going in the latest Txp (and I couldn’t figure it out, though admittedly I didn’t put much effort into it) I’d wager Quick Tags are your best bet for offering this kind of functionality.


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

#52 2011-09-05 14:53:44

stephan
Plugin Author
From: Bochum, Germany
Registered: 2004-07-26
Posts: 196
Website

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

Thanks, I shall give it a try and see how it works.

Update: OK, upm_quicktags was really simple to hack together so I could easily use smd_macro. Now also smd_gallery is as simple to integrate as pushing a buttong and putting some numbers in.
Thanks a lot for the wonderful plugins :-)

Last edited by stephan (2011-09-05 20:12:20)


Yoko for Textpattern – A free blog themeMinimum Theme – If all you want to do is write.
Note: I am currently not actively using Textpattern, so I am not in the forums very often

Offline

#53 2011-11-11 14:34:24

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

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

I need some jump-start: The plugin is activated, smd_macro is compatible with my TXP version, I copied the tag name from the macro tab, but my tag is displayed literally in the source code. What might be the reason?

This is my tag:

<txp:bildzoom Beschreibung="Wallachei 1" Gruppenname="wallachei" Grosses-Bild-ID="149" Kleines-Bild-ID="54" />

I also tried all lowercase attributes, but no luck.


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

Offline

#54 2011-11-11 14:46:21

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

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

uli wrote:

my tag is displayed literally in the source code.

Urk. Without further info, no idea off the top of my head. Can you export your macro please so I can try it on my server with your settings? That would then either rule out or confirm plugin bug / incompatibility / mashed page / pebkac.

Thanks.


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

#55 2011-11-11 14:50:11

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

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

Hi Stef,

this is the file contents:

[bildzoom2]
description = "Lightbox"
attributes[] = "Beschreibung||text"
attributes[] = "Gruppenname|wallachei|gruppe"
attributes[] = "Grosses-Bild-ID||groß"
attributes[] = "Kleines-Bild-ID||klein"
definition = "PGEgdGl0bGU9Int0ZXh0fSIgY2xhc3M9ImZjeWJ4IiByZWw9IntncnVwcGV9IiBocmVmPSJodHRwOi8vbWFyaW5hLWJydW5vcmkuZGUvaW1hZ2VzL3tncm/Dn30uanBnIj48dHhwOmltYWdlIGNsYXNzPSJmbG9hdC1yIiBpZD0ie2tsZWlufSIgLz48L2E+"

Thanks for taking the time to look into it!
Uli


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

Offline

#56 2011-11-11 15:03:10

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

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

BTW, the file is a cloned export. Like iI said: I copied the macro name, so the 2 isn’t the reason. Just remarked the radix sign and tested with ASCII: still no joy.


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

Offline

#57 2011-11-11 15:12:59

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

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

Uli

A few things. All of them to do with the plugin being too limited:

  1. At present, using dashes is not a good idea in attribute names. Switching to underscores made the tag work for me. I think this might be a PHP restriction as I don’t think variable/attribute names can contain dashes (not sure). I should probably outlaw their use in the plugin if that’s the case. Will fix either way.
  2. Your attributes should probably be defined in all lower case. I’m not sure how much difference it actually makes — probably not a lot — but it may be that the plugin assumes you’ll be using them lower case so it could be getting confused
  3. Using groß as a replacement is likely to confuse things because the column names aren’t defined as UTF-8. When I import the macro, for example, the replacement text is gro?? on my server. That needs fixing in the next release.

To summarize, swap dashes for underscores and stick to ASCII attribute names/replacements. Using lower case is a last resort if the previous two workarounds don’t have any impact.

A more international-friendly version of the plugin will be available when I get a chance. Sorry for the headaches and short-sightedness of the code.


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

#58 2011-11-11 15:28:50

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

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

Stef, thank you very much for this lightning-fast response. All is working now :)

The hyphens were inserted by the plugin itself, I was so stupid to use blanks =0 which would’ve worked nowayneverever, so pebkac was the true reason. Thanks again for helping and for this wonderful machine.


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

Offline

#59 2011-11-11 16:14:49

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

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

uli wrote:

The hyphens were inserted by the plugin itself

Oh lordy me, I’ll have to tend to that: it’s embarrassing. Thanks for letting me know.


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

#60 2011-11-11 16:26:57

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

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

PEBKAC ?? never heard that one before – had to look it up. Very funny!


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB