Setting Default Language via Category with jQuery

More
9 years 8 months ago - 9 years 8 months ago #62756 by iamrobert
If you use 2 languages, my clients often forget to set the correct language for the item when creating a new item and they leave it at "ALL"..

So - if I add the following code to my admin template js - it will choose English by Default.

For instance my maincat with category id 10 is "clients" and is in English.
Code:
if (window.location.href.indexOf("&maincat=10") > -1) { $(document).ready(function(){ $("select#jform_language").val("en-GB"); }); }

You can also do it via type.
Code:
if (window.location.href.indexOf("&typeid=23") > -1) { $(document).ready(function(){ $("select#jform_language").val("en-GB"); }); }
Last edit: 9 years 8 months ago by iamrobert.

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

More
9 years 8 months ago - 9 years 8 months ago #62758 by germany_bw
You can also set default language for new items in fc-global config in TAB "item form" or alternativ for each content type an other language as default in its config. (then in TAB "Item Form FE")
Last edit: 9 years 8 months ago by germany_bw.

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

More
9 years 8 months ago - 9 years 8 months ago #62765 by iamrobert
Thanks - I was more meaning - you can set it for multiple languages - which means you don't need to worry about maintaining multiple content types based on languages. Also - you can add it in FLEXIContent type - Item Form BE tab under JS.

So - you can do this:



Code:
/* CHINESE */ if (window.location.href.indexOf("&typeid=23&maincat=61") > -1) { $(document).ready(function(){ $("select#jform_language").val("zh-TW"); $("select#jform_catid.scat").val("61"); }); }
Last edit: 9 years 8 months ago by iamrobert.

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

More
9 years 8 months ago - 9 years 8 months ago #62766 by micker
maybe i can add this in my admin module ?
set type cat language

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]
Last edit: 9 years 8 months ago by micker.

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

More
9 years 7 months ago #62842 by iamrobert
Hi MIcker,

It would be awesome.

However - I don't think there is a way to pass the language through the URL:
www.flexicontent.org/forum/20-general-su...tom-url-filters.html

Thanks,

Robert

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

More
9 years 7 months ago #62843 by micker
i will ask to georgios about model

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

More
6 years 3 months ago - 6 years 3 months ago #77453 by iamrobert
Updated Code that works better with select2.js:

Via Category
Code:
(function($) { //VIA URL $(document).ready(function() { if (window.location.href.indexOf("&maincat=114") > -1) { $('#jform_language').val('en-GB'); // Select the option with a value of 'en-GB' $('#jform_language').trigger('change'); } }); }); })(jQuery);


Data Title:
In multi-lingual sites the the top level categories of the site are usually the languages (English & Chinese (中文)):







The top category uses data-title English or Chinese (中文):




So we can set this way:
Code:
(function($) { //VIA DATA TITLE $(document).ready(function() { var data = $("#jform_catid option:selected").attr('data-title'); if (data == 'English') { $('#jform_language').val('en-GB'); $('#jform_language').trigger('change'); } if (data == '中文') { $('#jform_language').val('zh-TW'); $('#jform_language').trigger('change'); } $('select#jform_catid').on('change', function() { var data = $("#jform_catid option:selected").attr('data-title'); if (data == 'English') { $('#jform_language').val('en-GB'); // Select the option with a value of 'en-GB' $('#jform_language').trigger('change'); } if (data == '中文') { $('#jform_language').val('zh-TW'); // Select the option with a value of 'zh-TW' $('#jform_language').trigger('change'); } }); }); })(jQuery);
Last edit: 6 years 3 months ago by iamrobert.

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

More
6 years 3 months ago #77454 by micker
cool you can do it with dashboard module V2 module too without js

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

More
6 years 3 months ago #77455 by iamrobert
Thanks - I was sharing as option 2 allows the user to swap languages automatically in new items based on category:



which has been one feature that has been bugging me forever.

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

More
6 years 3 months ago #77456 by micker
oh cool can it be more generic ?

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save