Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#101 2014-07-07 08:02:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,637
Website

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

GugUser

Thank you very much. All your textpacks are now available for download from my 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

#102 2014-10-30 10:27:50

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

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

This is very useful, I’ve used it to make a nice custom textpattern tag. One thing I don’t seem to be able to do however is add a second attribute, I don’t have a + option on the latest version of textpattern? Is this me, or a known issue, or a change??

Thank you

  • solved looks like, you have to press “ smd_macro_att_clone”, that’s the new +. Whoddathunkit :)

Last edited by ingleslenobel (2014-10-30 10:31:12)

Offline

#103 2014-10-30 10:40:06

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,637
Website

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

ingleslenobel wrote #285244:

looks like, you have to press “ smd_macro_att_clone”, that’s the new +.

Sounds like the plugin’s Textpack hasn’t been installed properly for some reason. You could try downloading this one, open it, copy the contents, visit your Admin->Preferences->Languages panel and paste the content in the Install textpack textarea at the bottom then hit Upload. That should sort out the rogue interface elements and restore your [+] button to its native glory.

Sorry about the hassle. No idea why it didn’t install properly. Are all the other strings OK?


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

#104 2014-10-30 12:42:36

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

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

Thank you Bloke – to be honest I’m fine with the text output now that I’ve actually discovered it – trying to click on a tiny + is much less friendlier than a nice long string of text!!! Though I appreciate I may bow to the inevitable as it might cause issues down the line – this is the only one I’ve come across though

Bloke wrote #285245:

Sounds like the plugin’s Textpack hasn’t been installed properly for some reason. You could try downloading this one, open it, copy the contents, visit your Admin->Preferences->Languages panel and paste the content in the Install textpack textarea at the bottom then hit Upload. That should sort out the rogue interface elements and restore your [+] button to its native glory.

Sorry about the hassle. No idea why it didn’t install properly. Are all the other strings OK?

p.

Offline

#105 2014-10-30 12:58:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,637
Website

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

ingleslenobel wrote #285254:

trying to click on a tiny + is much less friendlier than a nice long string of text!!!

Feel free to edit the smd_macro_att_clone language string in the textpack to [Add attribute] or whatever you prefer and re-upload it from the Languages panel.


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

#106 2014-10-30 15:42:19

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

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

done, thanks, that was easy =)

Bloke wrote #285256:

Feel free to edit the smd_macro_att_clone language string in the textpack to [Add attribute] or whatever you prefer and re-upload it from the Languages panel.

Offline

#107 2014-11-29 21:48:10

jagorny
Member
From: Portland, OR
Registered: 2006-08-24
Posts: 39
Website

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

Hi Stef,

Been testing the plugin and really like it so far. A have a small request, perhaps it doesn’t make sense to you but – well, this plugin has a lot of potential in helping bring over certain widget structures from another somewhat well known CMS system, but it would be really helpful – especially in certain applications, to be able to define a prefix and suffix value for an attribute – and if there is no value, then the entire compound is eliminated.

For example, trying to bring in a lightbox application, it is sometimes possible to simply switch the item ‘on’ using an ‘on;’ switch – other times you need to define a group using a “group:#VALUE;” switch.

It would be nice to be able to have the following attributes:

name / pre / default / post / replacement

switch / "" / "" / ";" / lbSwitch
group / "group:" / "" / ";" / lbGroup

That way I can create a macro like:

<a data-application="{lbSwitch}{lbGroup}" href="whocares"> etc etc

and not need to worry about adding extra characters or trying to run a conditional clause just to get the pre- and post- value constants in there only when they apply.

Does this make sense? I suppose this could be (ab)used in the form of inline styles and classes also – but I am finding that with a lot of jquery plugins it would be handy to be able to put in parameter names in the pre, semicolons in the post and then not worry about conditionals at all.

{Added Textile around code. – Uli}

Last edited by uli (2014-11-29 22:04:16)

Offline

#108 2014-11-30 15:21:08

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,892
Website

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

Not sure if I understood exactly what you’re trying to achieve, but maybe one of these helps:

1) If everything needs to be mega-flexible you could make the prefix and suffix attributes individual attributes of the macro and specify them each time.

2) Use smd_wrap to add a prefix or suffix to whatever it wraps.

You’ll need to test this but theoretically this:

<txp:smd_wrap prefix="group:" suffix=";">{lbGroup}</txp:smd_wrap>

will return group:yourname; if the group tag exists and nothing at all if the value is empty if it doesn’t.

3) Alternatively, you can use txp:variable / txp:if_variable to test whether a value is empty. smd_if will work too. Then you can construct your tag normally without recourse to smd_wrap.

<txp:variable name="group_var">{lbGroup}</txp:variable>
<txp:variable name="switch_var">{lbSwitch}</txp:variable>

<txp:if_variable name="switch_var" value=""></txp:else />
  <txp:variable name="switch_var">{lbSwitch};</txp:variable>
</txp:if_variable>
<txp:if_variable name="group_var" value=""></txp:else />
  <txp:variable name="group_var">group:{lbGroup};</txp:variable>
</txp:if_variable>

<a data-application="<txp:variable name="switch_var" /><txp:variable name="group_var" />" href="whocares">

And if you need to have the possibility to make an smd_macro have no value, see this thread.


TXP Builders – finely-crafted code, design and txp

Offline

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

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,415
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,313
Website

Offline

Board footer

Powered by FluxBB