Jump to content

New Fieldtype module needed (based on Events)


Remi
 Share

Recommended Posts

Hi!

I need a new fieldtype for my project. Basically it will be a modification of Events Fieldtype, so that it shouldn't be hard to do.

My field don't need "date" part. I would like to store in DB subfields:

sort, data (translation), translation_plain. I don't need "date" subfield.

I believe that "sort" subfield is clear. Translation and translation_plain subfields will store a short text (like in title field).

Translation_plain will have almost the same value as translation. The difference is, that I don't want to have any national letters in this field. They should be converted to ANSI.

For example: ą -> a, ę -> e, ś -> s, ł - > l, etc...

I need this behavior to make my search less accurate (YES - I need that).

That was a backend. Now the admin frontend:

Translation_plain subfield should be hidden (backend or js should take care on conversion). I want to change order of subfields by hand. Like in Repeater module.

Thats all.

Link to comment
Share on other sites

I'm not entirely sure what you are trying to achieve with this?

If you can explain what it is you want it to do more clearly that would help us to help you more.

If you just require multi-language support though, have you seen this page: http://processwire.com/api/multi-language-support/ ? That can be used to translate any text field.

  • Like 1
Link to comment
Share on other sites

I'm working on dictionary. Basically it works fine.

People very often type words in search field without national letters (like in old version based on Glossword). Because of that, search doesn't find all similar words.

Examples:

User want to find: sąd <court>

User type: sad <orchard>

Search found: sad (it should find also sąd)

User want to find: łaska <mercy>

User type: laska <stick>

Search found: laska (it should find also łaska)

Changing DB collations will solve this problem only partially. That's why I want to store two subfields with the "same" data.

I believe it can be optimized to save translation_plain only if there are natonal letters in translation subfield.

Link to comment
Share on other sites

dragan - I can do that by using another field. But it will make my site slower. I have ~30k pages with translations. My template has these fields:

title *

transcription

abbreviation *

part_of_speech

article

translation *

definition *

use_case *

* - searchable

I would like to switch field translation to something similar to Event fieldtype. Even without translation_plain it will be better for me. One word (page) can have many translations. It will also make search more accurate. I would like to sort translations by hand when they are already typed (in the Admin frontend).

Take a look:

Before:

https://www.dropbox.com/s/yp4b5cb68aqr0pg/PW-Before.png

After:

https://www.dropbox.com/s/jhk8o51ws46ukqc/PW-After.png

Link to comment
Share on other sites

I'm working on that, but I've got some problems...

On Edit Page I don't receive values for subfield clean from DB. But if I will put them, then they are stored in DB. I can also see them on default view page (See update).

I've got a problem on view page. Value of sort is always 0.

Can someone help me with these problems?

Update:

I've solved first problem. I've changed order of 2 lines in protected function renderRow() in InputfieldTranslations.module:

$clean = $this->sanitizer->entities($translation->clean);
$translation = $this->sanitizer->entities($translation->translation); 

Why it works and this don't:

$translation = $this->sanitizer->entities($translation->translation);
$clean = $this->sanitizer->entities($translation->clean);

???

FieldtypeTranslations.module

InputfieldTranslations.module

Translation.php

TranslationArray.php

Link to comment
Share on other sites

Remi, I'm not sure I fully understand the question, but it looks like you are getting a different result from swapping the order of your sanitizer calls? It should make no difference, but if it does then my best guess would be that something in the $translation object is getting changed as a result of accessing the 'clean' or 'translation' property. 

Link to comment
Share on other sites

  • 1 month later...

I've managed to do this module on my own. I can change it to store standard tables of text if somebody would be interested in that. It's possible to change order of the rows on the fly :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...