Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-11-13 10:39:45

saccade
Plugin Author
From: Neubeuern, Germany
Registered: 2004-11-05
Posts: 521

How to access plain body (the textile input) in $thisarticle or where?

Hi,
for a public plugin (that means within php) I’d need to get the non-html, textile – plain – version of body.
$thisarticle[‘body’] is the textile*d* html-version.
How can I get the plain body-field content without an extra query?

Offline

#2 2020-11-13 11:49:10

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

Re: How to access plain body (the textile input) in $thisarticle or where?

No way, I’m afraid. Here is the list of all populated fields, plus the custom ones:

            'thisid'          => 'ID',
            'posted'          => 'uPosted', // Calculated value!
            'expires'         => 'uExpires', // Calculated value!
            'modified'        => 'uLastMod', // Calculated value!
            'annotate'        => 'Annotate',
            'comments_invite' => 'AnnotateInvite',
            'authorid'        => 'AuthorID',
            'title'           => 'Title',
            'url_title'       => 'url_title',
            'description'     => 'description',
            'category1'       => 'Category1',
            'category2'       => 'Category2',
            'section'         => 'Section',
            'keywords'        => 'Keywords',
            'article_image'   => 'Image',
            'comments_count'  => 'comments_count',
            'body'            => 'Body_html',
            'excerpt'         => 'Excerpt_html',
            'override_form'   => 'override_form',
            'status'          => 'Status',

Offline

#3 2020-12-31 08:57:13

ax
Plugin Author
From: Germany
Registered: 2009-08-19
Posts: 165

Re: How to access plain body (the textile input) in $thisarticle or where?

There used to be a plugin named msv_show_article_field and then you could write:

<txp:msv_show_article_field name="Body" />

Since the source is no longer available, here is the PHP code:

function msv_show_article_field($atts) {
    global $thisarticle;
    $id = $thisarticle["thisid"];
    if (is_array($atts)) extract($atts);
    $fieldName = (empty($name)) ? "ID" : $name;
	if ($fieldName!="") {
	    $res = safe_rows($fieldName, "textpattern","id='$id'");
    	$out = $res[0][$fieldName];
  		return $out;
	}
}

Offline

#4 2020-12-31 13:46:45

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

Re: How to access plain body (the textile input) in $thisarticle or where?

If a db query is ok, you can make it shorter. Register fetch function for use in <txp:evaluate /> and call

<txp:evaluate query='fetch("Body", "textpattern", "id", <txp:article_id />)' />

Offline

Board footer

Powered by FluxBB