Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#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
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
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
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
Pages: 1