Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-03-01 15:58:25

singaz
Member
Registered: 2017-03-12
Posts: 150

Custom fields for the sections and for the categories

How can make Custom fields for the sections and for the categories?


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#2 2020-03-01 16:14:18

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

Re: Custom fields for the sections and for the categories

What kind of custom fields do you need?

One way I solved this issue was to create unsearchable, and unlisted sticky articles which replace the categories content. Check: github.com/colak/neme/blob/master/forms/list_cat2_projects.tpl where <txp:if_custom_field name="status" value="5"> checks for sticky articles. The form is linked from this template.


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

Offline

#3 2020-03-01 18:17:38

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

Re: Custom fields for the sections and for the categories

I have a very simple unpublished plugin that adds one / just a couple of normal text input fields to the section edit pane. It’s much like my jcr_image/file/link_custom plugins on GitHub. It works fine but is unpublished because it’s pretty bare-bones, i.e. there’s no UI for adding/removing/titling the custom fields. You have to do it in the plugin code. If you’re interested send me an email.

I use it for things like denoting a header image for a section that comes from flickr. If you’re using textpattern’s own images, you can match an image to your section easily via the image name. If you want to provide comprehensive info for a section, Yiannis’ suggestion of a sticky article is better.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2020-03-01 21:07:16

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: Custom fields for the sections and for the categories

Would like to have more freedom for SEO.

1. Need a field for the menu.

2. Need a field to display the extended name to section in the text.

3. Need a field for the standard title in the <head> block

4. Need a field for the image.

5. Canonical. Would like to be able to manually display or not display.

colak, thanks, I am studying.

jakob, thanks, I am sending email.

I try everything.

P.S. Sample images are taken at random.


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#5 2020-03-01 22:40:12

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

Re: Custom fields for the sections and for the categories

I’ve put the plugin up on GitHub and you can find it in two versions:

Please make a backup of your database first (please!). While both versions are in actual use on sites I’ve made, neither version has gone through any extensive testing. They’re txp version 4.7+ but I made both of them a while back and am a little rusty on what I did. See how you get on.

EDIT: updated GitHub links.


TXP Builders – finely-crafted code, design and txp

Offline

#6 2020-03-01 23:01:21

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: Custom fields for the sections and for the categories

Oh, very well! I will make the database copy and check. I will inform you about the results later.


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#7 2020-03-02 12:18:03

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: Custom fields for the sections and for the categories

I tried the multiple-fields jcr_section_custom plugin on two sites.
The plugin is installed and creates the fields in the table. But does not save the entered text. Checked on textpattern 4.8. And on demos here .

Great plugin idea. Very easy and open possibilities. I believe that this function should be introduced into the basic functionality of the engine – the possibilities for individual construction are expanding.


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#8 2020-03-02 14:26:03

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: Custom fields for the sections and for the categories

Need to write to the fields through the request:

UPDATE txp_section SET jcr_sec_custom_1 = ‘text for field jcr_sec_custom_1’ WHERE name = 'articles';

It is possible through the plugin rss_admin_db_manager

Last edited by singaz (2020-03-02 14:48:20)


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#9 2020-03-02 23:05:27

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

Re: Custom fields for the sections and for the categories

I resolved the saving problem but there’s more work to be done on the multiple version:

  • A naming UI for the custom fields under Admin › Settings
  • Make the output tag work not just in a section_list context but also on a regular page template.

I knew I shouldn’t have posted it so hastily… Apologies, I’ll get to it as soon as I can.

singaz wrote #322037:

I believe that this function should be introduced into the basic functionality of the engine.

One of the reasons I was holding back was that there is a general custom field capability planned for Textpattern (currently in a separate branch) and the more plugins that get out in the open in advance, the more there is to undo later. Ideally all these temporary file / link / image (and now section) custom plugins will be obsolete once the in-built functionality exists.


TXP Builders – finely-crafted code, design and txp

Offline

#10 2020-03-05 14:21:29

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

Re: Custom fields for the sections and for the categories

Singaz, I’ve uploaded an update to the multiple field version here.

Version 0.2 (still beta) now:

  • Saves the values correctly
  • Has a UI under Admin › Preferences for naming up to five custom fields (like the regular custom fields). Also reachable from the plugin “Options” link.
  • Only shows the named fields in the section edit pane.
  • The public jcr_section_custom tag works not just within a section_list tag but also on a regular page template.
  • wraptag, class and escape attribute support. In txp 4.8 the new escape attribute options are supported.
  • A new jcr_if_section_custom tag that works like the regular if_custom_field.

Again, pls make a backup of your DB for safety’s sake, then see how you get on with this version.

EDIT: updated GitHub links.


TXP Builders – finely-crafted code, design and txp

Offline

#11 2020-03-05 17:53:09

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: Custom fields for the sections and for the categories

Jakob, thank you!

Made a quick test.
It works great.

Tomorrow I will do a detailed test. And I will write about the results.

P.S.
Two translations

#@language ru-ru
jcr_section_custom => Поля пользователя секции
jcr_sec_custom_1 => Картинка секции
jcr_sec_custom_2 => Заголовок меню
jcr_sec_custom_3 => Заголовок страницы
jcr_sec_custom_4 => Цвет
jcr_sec_custom_5 => Цвет фона

#@language uk-uk
jcr_section_custom => Додатково до секції
jcr_sec_custom_1 => Зображення секції
jcr_sec_custom_2 => Заголовок меню
jcr_sec_custom_3 => Заголовок сторінки
jcr_sec_custom_4 => Колір
jcr_sec_custom_5 => Фоновий колір

Last edited by singaz (2020-03-06 00:15:15)


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

#12 2020-03-07 17:47:49

singaz
Member
Registered: 2017-03-12
Posts: 150

Re: Custom fields for the sections and for the categories

Now I am setting new site for version 4.8. The plugin works properly. So far no errors have been identified. Thank you for the plugin!


Sorry my horror English. I’m learning textpattern, I’m learning English

Offline

Board footer

Powered by FluxBB