List box & filter in a multilingual sites

Sylvain C. asked on May 30, 2019 20:45

Hi,
On my live site, I have a page which shows all the staff in my company. This site is bilingual (Spanish & English). The display of the staff works fine and each staff is formated based on my "Staff" page type with fields such as Name, phone, city and Program.

I would like to add list boxes in my staff webpage for filtering my staff by Program or/and by city for example.

First question:
How can I show in my view the list of programs/cities available? For the time being, in my admin site, for the "Staff" page type, it is stored for each field (City, Country) as required list boxes:
Program one
Program two

What would be the API code for extracting these lists in order to make them available in my view? I search everywhere, the documentation, the SQL Server DB but don't see where it is.

Second question:
As my site is bilingual, I would like to give my users the possibility to see these lists in both English and Spanish. As my lists in my page type are in English, it is not very convenient. What would be a better option? A separate table with both translations? And then what would be the way to make sure that the localization is used to display the correct list:
Program 1, program 2 for English user and Programa uno, programa dos for Spanish user.

Final remark:
When I will get the list, I will POST the value and will adapt my controller to filter my staff by the selected criterias. I found this example: https://docs.kentico.com/k12/e-commerce-features/developing-on-line-stores/displaying-product-listings/providing-product-filters but it is not very exhaustive. Would any of you would have other examples or links or at least tell me what is a SKU primitive?

Thank you again for your help

Sylvain

Recent Answers


David te Kloese answered on June 3, 2019 12:16

Hi,

Depending on your management needs (from the editor that need to update it) and dev needs, I'd recommend using either a Custom Table (which the client can manage if needed). If you need this in your code a lot you could also create a custom module and custom class so you can generate a provider and info-item-object which gives you a strongly typed "program"-item in your code. But last is a bit more work..

Then for the field (either custom table or class) use a Localizable text box form control:

localizable text box

This way you can use the default Kentico localization module for possible translations.

You can use the item ID (from custom table or custom class) for your filtering.

1 votesVote for this answer Mark as a Correct answer

Linda Sierra answered on June 3, 2019 16:41

Thanks for answer. very relevant and useful

0 votesVote for this answer Mark as a Correct answer

Sylvain C. answered on June 4, 2019 01:02 (last edited on June 4, 2019 01:43)

Thank you David for your answer.

I did as you said by creating a custom table and add a "ProgramName" and "ProgramID" fields.

How can I pass it to my view? I tried: IEnumerable<ProgramList> allPrograms = CustomTableItemProvider.GetItems<ProgramList>(customTableClassName); in my controller and then in my view: @Html.DropDownListFor(m => m.Data.ProgramSelected, new SelectList(Model.Data.AllPrograms, "ProgramID", "ProgramName"), "- Please Select -", new { @class = "browser-default" }) with the following model

public class ProgramList
{
    public string ProgramID { get; set; }
    public string ProgramName { get; set; }
}

But I get an error in the controller (No overload for method GetItems take 1 arguments)...

Any ideas

Also, wouldn't it be asier to have the translation directly in the custom tables instead of using the resource strings? If you have a table of countries for example with 200 records, it is going to be tricky to manage in the resource strings? What do you think?

S.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.