Populate a new list of checkboxes (multi Value) based on the input of another list of checkboxes (Multi Value)

14 posts by 2 authors in: Forums > CMS Builder
Last Post: January 17, 2017   (RSS)

By andybarn - January 9, 2017

Hi

I have a multilingual Website (3 languages) for a property Website and I use one section editor and create separate fileds for the languages for example for description I have 3 text boxes as follows

Field Label                                Field Name
Full Descriptiom (ENG)              description
Full Description (ESP)               esp_description
Full Description (FRA)               fra_descriprion

I then have 3 different HTML templates that I use depending on which country is selected.

However I also have a  features section that uses checkboxes (Multi Value) and I have 42 different options to select from as below.

Air-conditioning
Alarm system
BBQ area
BBQ
Central heating
Close to amenities
Communal garden
Covered parking
Double glazing
En-suite bathroom
Electric shutters
Fenced property
Fireplace
Furnished
Garage
Gated complex
Golf course views
Heating
Internet
Jacuzzi
Lift
No Community Fees
No Pets
Unfurnished
Off-road parking
Part furnished
Pets allowed
Pool view
Private driveway
Private garden
Roof terrace
Satellite TV
Sea view
Solar water heater
South facing
Storeroom
Summer Kitchen
Underfloor heating
Walking distance to beach
Window security grills
Window shutters
Wood burner

The problem is it is very time consuming for my client to enter features 3 times (for each language) as the list fields for each checkbox is one below the other.

Now I have the translations for all the features so ideally I want to be able to select the features on the English check boxes and this automatically pulls in the translation on the other checkboxes for the other 2 languages. Is there a way I can do that?

Alternatively, is there a way I can display the Features checkboxes side by side for each language so the client can just select each one on the same row without having to know the translation for the English word?

Any help or suggestions would be much appreciated.

Thanks
Andy

By ross - January 9, 2017

Hi Andy

Thanks for posting.

There are going to be a bunch of different ways to set this up.

When creating the new listings, are you and your editors ok if the "Features" are only listed in English? 

If that works, what you could do is create a new section called "Features". Set it up with three text fields, the labels and names can be "English", "French", "Spanish".

Then, you'd need to create one record in this section for each of the features available and enter the name in each language.

Next, in your listings section, create a new list field and have it pull the values from "Features" section. 

This will give you a list of all the features (in one language) to select from for each listing.

On your detail pages, you'll just need to do a look up for each feature selected to get it's name in the appropriate language.

Does that make sense?

Let me know any questions or feedback.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By andybarn - January 9, 2017

Hi Ross

Thanks for your reply.

I think I understand where you are coming from and am keen to get this working so in answer to your question, yes I am happy for the features to be only listed in English.

So my questions are

1) I have created a new section as suggested called Features, and set it up with 3 fields called english, spanish, french as suggested. This has been set as a Multi Record is that correct?

2) I have created several records in the features section for each feature in the 3 languages. When I create a new list field in my listings section, how do I pull the values from the "Features" section?

3) On my details page, how do I do a lookup for each feature selected to get its name in the appropriate language? at the moment I display features as 

<?php echo join(', ', $listingsRecord['features:values']); ?>



Thanks for your help with this.

If I can get it working, it will open up new possibilities for me as I will be able to do the same for other list fields such as "Property Type", "Views", "Banner Status" etc.

I look forward to hearing from you.

Andy

By ross - January 10, 2017

Hi Andy

Let's focus on creating the field in your listing section first.

In the Section Editor for your listings section use the "Quick Add" option to create a new "list" field.

Once the field is created, click modify next to it.

First thing here is to look for "Display As". Set that to "checkboxes (multi value)".

Next, right below that, look for "List Options"

There is a drop down with the default value of: Use options listed below

Change that menu to the option that reads: Get Options From Database (advanced)

For "Section Tablename", select your Features table

For "Use this field for option values", select the "num" field.

For "Use this field for option labels", select the "English" field.

And that should be it. Hit save and go back and try creating or modifying a record in your listings section and you should see the new list of checkboxes.

Give this a shot and let me know how you make out.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Hi Ross

Excellent! That worked perfectly! 

Please let me know the next steps.

Thanks for your help.

Andy

By ross - January 12, 2017

Hi Andy

The next step is to setup your front end detail pages.

Do you already have them setup? 

If so, could you post a copy of each (as attachments) so I can review the code?

Please make sure you have some indication on the page where you want the features to be displayed.

Thanks

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

Hi Ross

Yes I have details pages setup and attach for your reference.

listingDetail_test.php
listingDetail_test_esp.php
listingDetail_test_fra.php

You can view a property by going to:

http://www.sunsetjavea.com/property/listingDetail_test.php?248 
http://www.sunsetjavea.com/property/listingDetail_test_esp.php?248
http://www.sunsetjavea.com/property/listingDetail_test_fra.php?248

I have 2 fields setup for features

features (old list)
property_features (new list pulling data from Section Tablename features that I created as instructed)

The code on the page for features is on line 297

I have translated the features in the features table but not the rest of the page at this moment. However for testing purposes we should have enough to prove the features are working in the different languages.

I look forward to hearing from you and thanks again for your help with this.

Andy

Hi Ross

That would be great, look forward to hearing from you.

Kind regards

Andy

By ross - January 16, 2017

Hi Andy

Thanks for hanging on.

The next step is going to be trickier as we are now getting into the code. 

Here's a basic outline of what you'll need to do:

1. Loop through all the values stored in your "property_features" field. This works pretty much the same way as you are already displaying the original feature field you setup.

2. In each loop, you'll be working with the "num" value of each feature saved. You need to use that number to look up the full feature record from the other table you created.

3. Then, finally, you pick with field to display based on what language the rest of the page is in.

The code will look something like this:

<?php foreach ($listing['property_features'] as $feature):                      // loop through all features ?>
<?php $featureRecord = mysql_get("name of your new features table", $feature);  // load feature record ?>
<?php echo $featureRecord['es_feature'];                                        // display feature in language ?>
<?php endforeach ?>

Notes:

- I've highlighted a couple parts in red that you'll definitely need to change.

- you will likely need to play with the code a bit to get it working.

- notice how I am not using the :label option you were originally.  This is because we need the actual number stored in your database and not just the label.

- I can help you further with this step in consulting

Let me know any questions.

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/