Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2016-12-05 15:13:43

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

Re: Comparisons in custom_field matching in article(_custom)?

GugUser wrote #303171:

it would be helpful if the custom fields had names and titles, similar to the sections.

Nope. Names only. Titles are deferred to gTxt('my-custom-field-name') so they can be rendered in different languages, on both front- and admin-side.

Should be that way in the Sections panel, fwiw, but we have to live with it how it is.


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

Online

#14 2016-12-05 15:29:46

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: Comparisons in custom_field matching in article(_custom)?

Bloke wrote #303172:

Titles are deferred to gTxt('my-custom-field-name') so they can be rendered in different languages, on both front- and admin-side.

Have I lost the overview in the discussion? How would that work?

Offline

#15 2016-12-05 15:51:38

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

Re: Comparisons in custom_field matching in article(_custom)?

GugUser wrote #303174:

Have I lost the overview in the discussion?

I dunno. But it works that way on the admin side now. Try it out. Call one of your custom fields hr then visit the Write panel. You’ll see the custom field title horizontal rule. That’s gTxt() in action1.

If you add your custom field name to the txp_lang table it’ll use it (ymmv if you use spaces).

Currently you can’t output the custom field’s title on the public site because there’s no mechanism to do so. But in future, the <txp:custom_field> tag will have the ability to not only render the value of the custom field, but its meta data too (name, title, type, etc). If you elect to output its title, it will run the name through gTxt() and display it. Thus if you don’t have a translation it’ll show the custom-field-name instead.

The upshot is that you’ll be able to define a custom field called book-title and then define its name as:

  • Titre de livre (in fr)
  • Buchtitel (in de)

People with their admin side set to one of those two languages will see the appropriate label. If the public site is set to one of those languages you’ll be able to output the label in the public-side’s language too.

I haven’t figured out how best to administer this yet — probably as part of the multi-lingual stuff in future versions. The implementation I have right now has a Title field when you define a custom field but it stores it in the current language only. That needs fixing when I merge the latest codebase into the branch. Uhh, somehow.

Does that help?

1 Kudos to gaekwad for finding this: I never noticed until he pointed it out to me last month!

Last edited by Bloke (2016-12-05 16:08:06)


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

Online

#16 2016-12-05 15:59:27

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,473

Re: Comparisons in custom_field matching in article(_custom)?

Bloke wrote #303175:

Does that help?

That seems to be good, even if I don’t yet understand it 100%. I will see it in the future…

Offline

#17 2016-12-06 16:02:31

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

Re: Comparisons in custom_field matching in article(_custom)?

Bloke wrote #303161:

I like this. It should also be backwards compatible, because both month and time have been mutually exclusive so far.

I’ve tried to make it as bw compatible as possible, please test. Now we can output the upcoming articles with something like

<txp:article_custom month="now" time="+1 month" />

Anything that relates to global attributes, etc will be supported by virtue of them being processed as regular tag attributes. Not sure how it affects this use case, but since each custom field has a type and one such type is ‘date’, well, we could conceivably use the same mechanism for such attributes.

I guess it will be not before 4.8. And I would also consider a separator for custom fields that can carry multiple values (like Keywords, say).

Offline

#18 2021-06-25 08:42:30

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: Comparisons in custom_field matching in article(_custom)?

I stumbled over this old post. I would need exactly that. Is there a way already by testing in article_custom the customfield= against multiple different values?

Actually what I need is more somthing like a wildcard.

I am wondering why this works:

customfield='_%'

and this works

customfield='<txp:if_variable name="test" value="">0<txp:else/>1</txp:if_variable>'

but that does not work

customfield='<txp:if_variable name="test" value="">_%<txp:else/>1</txp:if_variable>'

EDIT: Just realized putting the if_variable outside of the article_custom make it work fine. Still a bit weird.

Last edited by demoncleaner (2021-06-25 09:07:22)

Offline

#19 2021-06-25 09:46:36

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

Re: Comparisons in custom_field matching in article(_custom)?

demoncleaner wrote #330672:

Is there a way already by testing in article_custom the customfield= against multiple different values?

Partially, if the values come from an URL variable: match="customfield" on ?customfield[]=one&customfield[]=two page.

but that does not work

customfield='<txp:if_variable name="test" value="">_%<txp:else/>1</txp:if_variable>'...

This works for me, the problem must be elsewhere.

Offline

#20 2021-06-25 20:35:24

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 220
Website

Re: Comparisons in custom_field matching in article(_custom)?

Ah ok thanks.
Yes indeed my whole setup was a bit more complex and the reason why it was not working came from elsewhere. But your comment helped me.

Offline

Board footer

Powered by FluxBB