Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2018-04-05 14:56:56

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

Re: Read content -> look for article with same name - link

Is it possible to be not strict on upper- or lowercase writing?


A hole turned upside down is a dome, when there’s also gravity.

Offline

#14 2018-04-05 15:22:41

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

Re: Read content -> look for article with same name - link

jayrope wrote #310665:

Is it possible to be not strict on upper- or lowercase writing?

Yes, but it’s way easier in 4.7 and we are really close to it:

<txp:if_custom_field name="works with">
<txp:variable name="replacements">{
<txp:article_custom break="," limit="999">
	"<txp:title escape="lower, json" />":"<txp:permlink escape="json"><txp:title /></txp:permlink>"
</txp:article_custom>
}</txp:variable>
<txp:etc_query data='<txp:custom_field name="works with" escape="lower" />' markup="raw"> 
	{$json_decode({?replacements}|1).strtr({?}|$)}
</txp:etc_query>
</txp:if_custom_field>

Offline

#15 2018-04-05 16:55:40

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

Re: Read content -> look for article with same name - link

Eventually i should wait until 4.7 then.
I looked at the variable output, but there doesn’t seem to be any obvious reason, why it doesn’t link multiple word terms.
Could it be a white space problem, is there a sort of URL-encoding in the way someplace maybe?

Wait, Uli said “Textile”… ????

EDIT: In fact, the rah_replace code has the same problem. Ai!

Last edited by jayrope (2018-04-05 17:08:17)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#16 2018-04-05 17:19:09

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

Re: Read content -> look for article with same name - link

If a title contains one or more of <'"> characters, then yes, it’s an encoding problem. Or maybe glz_cf interferes? Let’s test on Pete’s demo site. Edit: no, his 4.6 is disabled.

Offline

#17 2018-04-05 17:30:05

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

Re: Read content -> look for article with same name - link

At least, 4.7 works. And btw, where have you put this code? If it is in articles body/excerpt then you should prevent it from being Textiled, as Uli says.

Offline

#18 2018-04-05 17:50:38

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

Re: Read content -> look for article with same name - link

I have put my code into a “miscellaneous” form, which is called by an article form upon display of an individual article.
However, i only read content from a custom field, not from excerpt or body. Is there a way to shut off textile from inside your code?

Last edited by jayrope (2018-04-05 17:51:47)


A hole turned upside down is a dome, when there’s also gravity.

Offline

#19 2018-04-05 17:58:25

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

Re: Read content -> look for article with same name - link

Custom fields are not textiled, but HTML escaped, and unfortunately differently from the title. You can try to set escape="" both in <txp:title /> and <txp:custom_field /> calls.

Offline

#20 2018-04-07 15:06:12

jayrope
Plugin Author
From: Berlin
Registered: 2006-07-06
Posts: 687
Website Mastodon

Re: Read content -> look for article with same name - link

Okay, escape="" doesn’t do it here. Somehow i am guessing, that 4.7 isn’t further than maybe two weeks away. So maybe i should just wait it out. If glz_cf and smd_tags are ready by then as well, it could be much easier.
It couldn’t be php 7 related? i only recently switched, maybe there is a certain php lib missing?

Extensions installed are PHP extensions: Core/7.0.29, date/7.0.29, libxml/7.0.29, openssl/7.0.29, pcre/7.0.29, sqlite3/7.0.29, zlib/7.0.29, bz2/7.0.29, calendar/7.0.29, ctype/7.0.29, curl/7.0.29, hash/1.0, filter/7.0.29, ftp/7.0.29, gettext/7.0.29, gmp/7.0.29, SPL/7.0.29, iconv/7.0.29, pcntl/7.0.29, readline/7.0.29, Reflection/7.0.29, session/7.0.29, standard/7.0.29, shmop/7.0.29, SimpleXML/7.0.29, mbstring/7.0.29, tokenizer/7.0.29, xml/7.0.29, litespeed, bcmath/7.0.29, dom/20031129, enchant/7.0.29, fileinfo/1.0.5, gd/7.0.29, imagick/3.4.3RC4, imap/7.0.29, intl/1.1.0, json/1.4.0, exif/7.0.29, mcrypt/7.0.29, mysqli/7.0.29, mysqlnd/mysqlnd 5.0.12-dev – 20150407 – $Id: b5c5906d452ec590732a93b051f3827e02749b83 $, PDO/7.0.29, pdo_mysql/7.0.29, pdo_sqlite/7.0.29, pgsql/7.0.29, Phar/2.0.2, posix/7.0.29, pspell/7.0.29, soap/7.0.29, sockets/7.0.29, stats/2.0.3, tidy/7.0.29, wddx/7.0.29, xmlreader/7.0.29, xmlrpc/7.0.29, xmlwriter/7.0.29, xsl/7.0.29, zip/1.13.5


A hole turned upside down is a dome, when there’s also gravity.

Offline

#21 2018-04-07 20:05:03

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,596
Website

Re: Read content -> look for article with same name - link

Okay, escape=”“ doesn’t do it here.

Perhaps you can show us what output you are getting with each setting and what output you want to have?

Oleg, exactly, extracting comma-separated article titles from a custom field, then replace the respective entries with links to the respective articles in the same field, only in frontend, so only for display (yet ;).

In fact really cool would be, if i get a live list of existing article titles, when starting to type terms into that custom field in the backend. But that’s version “future”.

Is this what you are really trying to achieve? A custom field where you can specify other related articles that are then output as associated links in the front end?

If so, take a look back at a suggestion I made a few weeks back of using a custom scripts custom_field. That gives you a drop-down of a list of articles (you can decide which sections, filtering criteria you wish to apply by changing the query) and what gets saved to your custom field is a list of article id numbers that you can plug straight into txp:article_custom (possibly via rah_replace first). UI-wise it’s not the live-search list of articles you mention but rather a list of the actual titles to choose from but it’s a whole lot more robust than matching typed title strings to a list of titles and links. Adapting the sql query is easier than a special regex to match titles too. And if you use bsmSelect which I linked to too, you can also change the order.

EDIT: I used exactly the code posted in the other thread for the custom field script and loaded bsmSelect through bot_wtc’s script field. You get a custom field that holds 12|9|16|7 or similar (depending on the articles chosen). This is the code snippet I used to output the corresponding links:

<txp:if_custom_field name="main_contact" value=""><txp:else />
    <h2>Main contact<txp:smd_if field="main_contact" operator="contains" value="|">s</txp:smd_if></h2>
    <txp:article_custom id='<txp:rah_replace from="|" to="," delimiter=":"><txp:custom_field name="main_contact" /></txp:rah_replace>' break="li" wraptag="ul">
<txp:permlink /><txp:title /></txp:permlink>
    </txp:article_custom>
</txp:if_custom_field>

That was a couple of txp versions ago, too. Essentially it was a way of assigning the contact details of several project partners to a particular project.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB