Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Multilingual filter 05 Sep 2018 06:25 #15608

Hi every one !
Lets say, we have a category table with the following fields :
- id
- title (default field)
- title_en
- ...

I would like to show title or title_en field in the filter combo depending on language selected by the user.
For the moment, I found a few tricks but none of them works completly...
What would be the best way to do it ?

Thanks in advance,
Best regards,
Fred

Please Log in or Create an account to join the conversation.

Last edit: by Frederic.

Multilingual filter 09 Sep 2018 18:39 #15609

So, Admin are you there ?

Please Log in or Create an account to join the conversation.

Multilingual filter 21 Sep 2018 12:36 #15610

So I feel very lonely here... :(

Any idea welcome !

I search the forum but it did not help.

TIA
Best,
Fred

Please Log in or Create an account to join the conversation.

Last edit: by Frederic.

Multilingual filter 23 Sep 2018 19:10 #15611

Hi there,

I do not think you want to add a field for every language you need ;)
How is this category table filled? Is it a table you have in your component?
And can an item be in only on or more categories?

Please Log in or Create an account to join the conversation.

Multilingual filter 25 Sep 2018 07:20 #15612

Hi Romkabouter,

Thank you for your answer, I feel a bit less lonely.

This project is stricly bi-lingual. You are right, having a text field for each language would be crazy otherwise.

Yes, the category table is inside my component and its contents change very often so using a language INI file is not a solution...
And Yes, an item is related to only one category.

What do you suggest ?

Best regards,
Fred

Please Log in or Create an account to join the conversation.

Last edit: by Frederic.

Multilingual filter 25 Sep 2018 18:30 #15613

I don't know how much of a developer you are, but read about forking your component here:
www.j-cook.pro/index.php/f/forks

In the view of the items there is probably something like
		$filters['filter_XXX']->jdomOptions = array(
			'list' => $modelXXX->getItems()
		);
for the categories. (I do not know your code, so try to find it yourself)

That "list" needs to get filled with either the title or title_en, you can do that by overriding your model.

Can you post some screenshots of your builder or folderstructure? I can then give better pointers as to where to change things :)

Please Log in or Create an account to join the conversation.

Multilingual filter 28 Sep 2018 16:48 #15615

Hi Romkabouter,
Thank you for your help. Maybe, I am not so far from the solution...

Here what I have done :
Forking the view :
// Catégorie > Titre
		$modelCategory = CkJModel::getInstance('categories', 'Cmp18Model');
		$modelCategory->set('context', $model->get('context'));
		$nomFiltre = ($lg == 'fr') ? 'filter_category':'filter_category_en';
		$filters[$nomFiltre]->jdomOptions = array(
			'list' => $modelCategory->getItems()
		);
Forking the items having a category field to filter on, I modify the models/forms/object.xml that way :
<field name="filter_category"
				listKey="id"
				labelKey="libelle"
				type="ckcombo"
				submit="true"
				nullLabel="CMPLUTECE18_FILTER_NULL_CHOISIR_UNE_CATEGORIE"
				class="span-2 element-filter"
				label="CMPLUTECE18_JSEARCH_CATEGORIE_TITRE"
				ui="chosen"/>

		<field name="filter_category_en"
				listKey="id"
				labelKey="libelle_en"
				type="ckcombo"
				submit="true"
				nullLabel="CMPLUTECE18_FILTER_NULL_CHOISIR_UNE_CATEGORIE"
				class="span-2 element-filter"
				label="CMPLUTECE18_JSEARCH_CATEGORIE_TITRE"
				ui="chosen"/>

In the model categories.pfp file, I forked the prepareQuery function to order the query on libelle or libelle_en field depending on the selected language.

With these modifications done, I am able to get the filter combo for category filled with the selected language and it is well ordered... Great ! but...

What is not working... :(

In English, when a filter is applied, the combo box does not display the selected value as it does in french...

Any idea ? Or another way to do it ?

Best regards,
Fred

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.111 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started