Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-07-05 16:07:43

MarcoK
Plugin Author
From: Como
Registered: 2006-10-17
Posts: 248
Website

Parse an article before post on frontend

There is a way to parse with custom php function an article before show on frontend without modify the code saved into database?

I’m serching a way to transform url into hyperurl and youtube url into embed video like a classical forum function,
or a way to transform smily code into image.

Any ideas?

Offline

#2 2012-07-06 07:34:06

milosevic
Member
From: Madrid, Spain
Registered: 2005-09-19
Posts: 390

Re: Parse an article before post on frontend

Maybe smd_macro can help you.

With it you can build your own txp functions like “<txp:video id=“youtube-video-url”/>, in some way it is like using txp:output_form in articles but more simplex and powerfull.


<txp:rocks/>

Offline

#3 2012-07-06 09:21:19

etc
Developer
Registered: 2010-11-11
Posts: 5,192
Website GitHub

Re: Parse an article before post on frontend

For simple replacements (smileys, and so on), an7_filter works well. For more elaborated ones, you could try etc_query, though it may be tricky:

<txp:etc_query data='<txp:body />' replace="//a[contains(@href,'youtube')]@@src={[@]href}@href@#=iframe" />

will work for embedded videos, like in <a href="http://www.youtube-nocookie.com/embed/oNvb2SjVjjI?html5=1">AdBlock Plus</a>, if you put it instead of <txp:body /> in article form.

Last edited by etc (2012-07-06 09:30:22)

Offline

#4 2012-07-06 10:27:48

MarcoK
Plugin Author
From: Como
Registered: 2006-10-17
Posts: 248
Website

Re: Parse an article before post on frontend

Thanks Milosevic and etc

an7_filert is a good idea to start my plugin…

Offline

Board footer

Powered by FluxBB