Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Help me with TextileThis() for titles. No php knowledge.
I’ve tried <txp:php>TextileThis("test") </txp:php>
Of course it failed. Any help please?
I need articles’ titles to appear with textile modifications, like smartquotes etc.
Last edited by maratnugmanov (2013-03-03 14:24:24)
Offline
Re: Help me with TextileThis() for titles. No php knowledge.
Basics you will need;
- Import the library.
- Get the article’s title.
- Access the actual parser functionality of Textile; there is no global function TextileThis().
- Echo the parsed contents to the template.
The downfalls;
- Parsing takes server resources.
- The titles are preprocessed during saving.
Which would make processing the titles during saving through an admin-side plugin a way better option. That aside, you can do on the fly Textile parsing in your templates if you need to. There even are plugins and tags that can do that for you, like upm_textile.
<txp:upm_textile><txp:title /></txp:upm_textile>
To access Textile’s parser capabilities in raw PHP under Textpattern 4.5.x you will have to first import the library, after you can access the Textile::TextileThis()
method. The library itself is located in /lib/classTextile.php file.
You can access an article’s title using normal tag markup wrapped in a parse()
(e.g. parse('<txp:title />')
), or by calling the tag handler function, title()
(e.g. title(array())
), directly.
<txp:php>
include_once txpath.'/lib/classTextile.php';
$textile = new Textile($prefs['doctype']);
echo $textile->TextileThis(title(array()));
</txp:php>
On 4.6-dev you have a pre-configured Textpattern_Textile_Parser
class, and accessing the Textile class directly is unrecommended. 4.6-dev branch uses autoloading, so you don’t need to import any libraries either. This reduces the requires code to few lines, and takes away any need for any additional configuration like setting the doctype.
<txp:php>
$textile = new Textpattern_Textile_Parser();
echo $textile->TextileThis(title(array()));
</txp:php>
Last edited by Gocom (2013-03-03 14:56:28)
Offline
Re: Help me with TextileThis() for titles. No php knowledge.
Damn, I only wanted to have localized quotes. Thanks anyway. I couldn’t predict getting so detailed answer – it will help me a lot.
Offline
Re: Help me with TextileThis() for titles. No php knowledge.
Tedious I know, but you can use html entities in TXP article titles e.g. “
and ”
for your open and close double quotes. You can either add them directly in the write tab or, if appropriate, incorporate them in the TXP article form. That may go some way to meeting your requirement.
Offline