Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2016-10-18 15:11:13

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

I’m sad.
Ok, it’s not a Troubleshooting because it was a non documented feature. But i liked it !

With Texpattern ≤ 4.5.7 it was possible to write some Textile text to body field and write Textile footnotes or links alias to excerpt field. I don’t now why by the 2 fields was analysed together by Textile parser.

I used this feature for move footnotes to a sidebar for example. You can see a exemple to my website (only for viewport > 10124px, in 2 cols layout) : Click on green number in body text, and after scroll page.

ok, I played with fire.
Now with 4.6, this feature stopped
I need to find a solution to patch my problem.

  1. Someone has a sql code to move except content à the end of body content ?
  2. And after that I need to find solution for wrap footnotes and move to sidebar…

Ay help or ideas welcome

Thanks

Offline

#2 2016-10-20 09:56:42

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: 4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

Cast Away

Offline

#3 2016-10-20 10:46:31

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,011
Website GitHub Mastodon Twitter

Re: 4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

It might be a lot of work but did you think of using the images fields? You could for example upload some 1×1px images just to create entries in the database and use them for your own needs.

Something like <txp:images id="##"><txp:image_info type="caption" /><txp:images>

The image id could be fetched by a custom_field in the article, which you could call footnotes. In such case the code above could change to

<txp:if_custom_field name="footnotes">
<txp:else />
<txp:images id='<txp:custom_field name="footnotes" />'>
<txp:image_info type="caption" escape="" />
</txp:images>
</txp:if_custom_field>

Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#4 2016-10-20 13:06:24

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

Re: 4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

sacripant wrote #302297:

Someone has a sql code to move except content à the end of body content ?

That’s rather straightforward:

UPDATE `textpattern` SET `Body` = CONCAT(`Body`, '\n\n', `Excerpt`), `Body_html` = CONCAT(`Body_htm`, '\n', `Excerpt_html`) WHERE ...

And after that I need to find solution for wrap footnotes and move to sidebar…

You can wrap Excerpt_html in some markup when concatenating and use css/jquery/etc_query to display/move it where you want.

Offline

#5 2016-10-20 16:10:41

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

Re: 4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

You can kind of restore the 4.5.7 behaviour with this plugin (to test):

# Name: abc_merge v0.1 
# Type: Admin/AJAX plugin
# 
# Author: 
# URL: 
# Recommended load order: 5

# .....................................................................
# This is a plugin for Textpattern CMS - http://textpattern.com/
# To install: textpattern > admin > plugins
# Paste the following text into the 'Install plugin' box:
# .....................................................................

YToxMTp7czo0OiJuYW1lIjtzOjk6ImFiY19tZXJnZSI7czo2OiJhdXRob3IiO3M6MDoiIjtz
OjEwOiJhdXRob3JfdXJpIjtzOjA6IiI7czo3OiJ2ZXJzaW9uIjtzOjM6IjAuMSI7czoxMToi
ZGVzY3JpcHRpb24iO3M6MDoiIjtzOjQ6ImNvZGUiO3M6NTcwOiJyZWdpc3Rlcl9jYWxsYmFj
aygnYWJjX21lcmdlJywgJ2FydGljbGVfc2F2ZWQnKTsNCnJlZ2lzdGVyX2NhbGxiYWNrKCdh
YmNfbWVyZ2UnLCAnYXJ0aWNsZV9wb3N0ZWQnKTsNCg0KZnVuY3Rpb24gYWJjX21lcmdlKCRl
dmVudCwgJHN0ZXAsICRycykgew0KCWlmICghKCRyb3cgPSBzYWZlX3JvdygnQm9keSwgRXhj
ZXJwdCcsICd0ZXh0cGF0dGVybicsICdJRD0nLiRyc1snSUQnXSkpKSByZXR1cm47DQoJZXh0
cmFjdCgkcm93KTsNCgkkdGV4dGlsZSA9IG5ldyBcVGV4dHBhdHRlcm5cVGV4dGlsZVxQYXJz
ZXIoKTsNCgkkbWVyZ2VkID0gJHRleHRpbGUtPnRleHRpbGVUaGlzKCRCb2R5Lm4ubi4nbm90
ZXh0aWxlLiA9PT09PT09PT09Jy5uLm4uJEV4Y2VycHQpOw0KCWxpc3QoJGJvZHlfaHRtbCwg
JGV4Y2VycHRfaHRtbCkgPSBkb1NsYXNoKGV4cGxvZGUobi4nPT09PT09PT09PScubiwgJG1l
cmdlZCwgMikpOw0KCXNhZmVfdXBkYXRlKCd0ZXh0cGF0dGVybicsICJCb2R5X2h0bWwgPSAn
JGJvZHlfaHRtbCcsIEV4Y2VycHRfaHRtbCA9ICckZXhjZXJwdF9odG1sJyIsICdJRCA9ICcu
JHJzWydJRCddKTsNCn0iO3M6NDoidHlwZSI7czoxOiI0IjtzOjU6Im9yZGVyIjtzOjE6IjUi
O3M6NToiZmxhZ3MiO3M6MToiMCI7czo0OiJoZWxwIjtiOjA7czozOiJtZDUiO3M6MzI6ImJi
MzRlMTJjOTBjZWY3Y2M1YTVhYmY5NGY5ZjViYTAxIjt9

Your Body and Excerpt must not contain ========== string :-)

Last edited by etc (2016-10-20 16:12:28)

Offline

#6 2016-10-25 20:28:02

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: 4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

@Colac, I’m not sure you understood my request

@etc. Excellent, my rescuer!

I moved Excerpt content to body content with sql “Update + Set” command when I see your plugin proposition.
Your small plugin work perfect.

Just some questions to better understand your code :

register_callback('abc_merge', 'article_saved');
register_callback('abc_merge', 'article_posted');

Why you need to launch abc_merge to article_saved AND article_posted callbacks ?

By default, a Textile parser is launched when you save article. A article_saved callback replace this default parsing or add a new function after (in this case, Parser is launched 2 times or not ?)

function abc_merge($event, $step, $rs) {
	if (!($row = safe_row('Body, Excerpt', 'textpattern', 'ID='.$rs['ID']))) return;
	extract($row);
	$textile = new \Textpattern\Textile\Parser();
	$merged = $textile->textileThis($Body.n.n.'notextile. =========='.n.n.$Excerpt);
	list($body_html, $excerpt_html) = doSlash(explode(n.'=========='.n, $merged, 2));
	safe_update('textpattern', "Body_html = '$body_html', Excerpt_html = '$excerpt_html'", 'ID = '.$rs['ID']);
}

If I understand your plugin,

  1. you extract (only if exist) Body and Excerpt from BDD,
  2. You merge the 2 fields and add between a specifique caracters list (.n.n.‘notextile. ======’.n.n)
  3. You launch textile parser to the merged result
  4. you split the result and save to *_html column in BDD

I find this very interesting because it’s possible to parse a specifique custom field and save/cache the result in another custom field.

Just for test: Textpattern offers a console.log function debuging for PHP ? Or what is the best way to test/display PHP vars values in browser ?

Offline

#7 2016-10-25 22:03:27

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

Re: 4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

Glad it helps.

sacripant wrote #302488:

Just some questions to better understand your code :

Why you need to launch abc_merge to article_saved AND article_posted callbacks ?

Because article_posted is fired only when you create a new article, and article_saved when you modify an existing article. In both cases we need to re-textile it.

By default, a Textile parser is launched when you save article. A article_saved callback replace this default parsing or add a new function after (in this case, Parser is launched 2 times or not ?)

Yes, twice, unfortunately, each time on the same texts (Body or Excerpt). In 4.6 you can(?) replace the default parsing of Body and Excerpt, but only separately.

If I understand your plugin,

  1. you extract (only if exist) Body and Excerpt from BDD,
  2. You merge the 2 fields and add between a specifique caracters list (.n.n.‘notextile. ==’.n.n)
  3. You launch textile parser to the merged result
  4. you split the result and save to *_html column in BDD

5 sur 5 :-) if we add that Excerpt_html contains now (in your case) the footnotes linked to Body_html.

Just for test: Textpattern offers a console.log function debuging for PHP ? Or what is the best way to test/display PHP vars values in browser ?

Not that I know. For debugging I merely include dmp($var) or var_dump($var) in the code. Sometimes forgetting to remove them afterwards… :-)

Offline

#8 2016-10-26 08:42:42

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: 4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

Textpattern offers a console.log function debuging for PHP?

Do you mean this ? I think that’s a js console but I’ve never used it.

Like etc, I tend to stick to dmp () for outputting PHP.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2016-10-26 09:25:44

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: 4.6 : Textiled Body & Excerpt are now analyzed separately, I'm sad

Do you mean this ? I think that’s a js console but I’ve never used it.

It look like a JS console.log with store logs in a history array and only if you are in ‘debug’ status.

I was thinking more of a function that makes a bridge between PHP and JS console like that.
For a beginner as me, it facilitates the understand of a plugin.

Offline

Board footer

Powered by FluxBB