Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-09-15 07:15:24

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Override Textpattern tag

Is it possible to create a plugin that will override a standard text pattern tag, e.g. <txp:permlink> ? Obviously re-declaring functions presents an issue so it can’t be done that way.

I’ve searched around a bit, but can’t seem to find anything on it (which surprises me).

Any feedback would be appreciated.

Last edited by radneck (2015-11-04 07:47:59)

Offline

#2 2010-09-15 09:04:43

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Override Textpattern tag

Why would you override a tag? You could just create a new one, which really is what you should do. As far as overriding functions (and tags) go, it’s not possible. The parser replaces the tags with functions and to replace a tag you would have to replace the original function which isn’t possible from Textpattern.

You should just build your own tags, and to avoid conflicts, prefix every function and class you use. See:

Offline

#3 2010-09-17 02:04:06

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: Override Textpattern tag

Hi Gocom,

Thanks for your reply.
I had previously studied the plugin dev guidelines, and it was only after I couldn’t find anything there that I came here.

The reason for wanting to override an existing tag is I want to make a version of <txp:permlink> that doesn’t include the rel=“bookmark” attribute. Rather than going through all my templates and forms and replacing each <txp:permlink> with <txp:my_new_permlink>, I thought it would be better if the exiting tag could be overridden.

I understand how tags are replaced with functions, and I think technically it might be able to be done with a healthy dose of override_function or rename_function, but this is not very practical as most people don’t have the ability to install APD on their servers. As such, I was hoping there was a way to hook in to Textpattern and override functions using a callback or something.

Unfortunately it seems unlikely that this is possible.

Last edited by radneck (2015-11-04 07:47:14)

Offline

#4 2010-09-17 10:13:51

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Override Textpattern tag

cain-mi wrote:

The reason for wanting to override an existing tag is I want to make a version of <txp:permlink> that doesn’t include the rel=“bookmark” attribute.

Fair enough; I’m not a fan of rel="bookmark" either.

Rather than going through all my templates and forms

If you do go this route, smd_where_used makes this pretty easy.

Rather than writing your own plugin, you might find wet_link does what you want, and more.


Code is topiary

Offline

#5 2010-09-19 04:26:57

radneck
Plugin Author
Registered: 2005-07-03
Posts: 109

Re: Override Textpattern tag

Thanks jsoo, smd_where_used looks quite useful.

Still, disregarding of my specific circumstance, it would be interesting to know if you could override a default Textpattern tag. At this stage it doesn’t seem possible however.

Offline

#6 2010-09-19 05:11:53

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: Override Textpattern tag

Overriding a Textpattern tag would require overriding its corresponding tag handler function. We have no built-in support for function overrides besides the ones provided by PHP itself.

Last edited by wet (2010-09-19 05:12:09)

Offline

Board footer

Powered by FluxBB