Welcome, Guest
Username: Password: Remember me

TOPIC: Limit Language Options on Survey List Page?

Limit Language Options on Survey List Page? 2 years 6 months ago #74169

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
What's the best way to limit the language options on the first page (with the list of surveys)? I can remove the languages I don't want from the database, or I can tweak the code, or the template, to only reflect those languages. Is there a "preferred" way?

I had made a suggestion on the ideas page to use a templating language like Twig or Smarty, which supports looping and logic so that if you pass an array of surveys (or survey objects), the template (aka View in MVC) could handle the display. What I'd really like to do is display the surveys with their language options all on one page. What I'll probably do is access the database from my own script and do that, but always like to know if there's a way to do it from within Lime.

Thx,

Tac
The administrator has disabled public write access.

Re: Limit Language Options on Survey List Page? 2 years 6 months ago #74170

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
Actually, I think I can be more specific. How can I customize

{LANGUAGECHANGER}

without modifying the underlying code? Is there a "hook" or something I can call that sets these kind of things?

Tac
The administrator has disabled public write access.

Re: Limit Language Options on Survey List Page? 2 years 6 months ago #74174

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
For those that are interested, here's how I solved it in a way that I think is generalized (rather than hacking the code for my specific languages).
# in config.php
$supportedLanguagesKeys = 'en,vi';
    # roughly line 571 in classes/core/surveytranslator.php

    // if $supportedLanguagesKeys is defined in config, filter
    if (!empty($GLOBALS['supportedLanguagesKeys']))
    foreach (array_keys($supportedLanguages) as $lang) {
      if (!in_array($lang, explode(',', $GLOBALS['supportedLanguagesKeys']))) {
        unset($supportedLanguages[$lang]);
      }
    }

Now only my languages, plus the base language, is displayed. To get rid of the redundant base language, do the following
# around 1152 in index.php

    } elseif (!isset($surveyid))
    {
        global $defaultlang, $baselang;
        $htmlcode = "<select name=\"select\" class='languagechanger' onchange=\"javascript:window.location=this.value\">\n";
#        $htmlcode .= "<option value=\"$relativeurl/index.php?lang=". $defaultlang ."$tokenparam\">".getLanguageNameFromCode($defaultlang,false)."</option>\n";
        foreach(getlanguagedata() as $key=>$val)
        {
            $htmlcode .= "\t<option value=\"$relativeurl/index.php?lang=".$key."$tokenparam\" ";
            if ($key == $baselang) $htmlcode .= " selected='selected'";
            $htmlcode .= ">".getLanguageNameFromCode($key,false)."</option>\n";
        }
        $htmlcode .= "</select>\n";

Basically it just pre-selects the base language from the list.

I'm not sure what the best way to get this into source control, as this is obviously something other people want. I want to thank the unnamed author of the post at http://blog.smerpup.com/2011/12/limesurvey-first-review/ who pointed me to the right files.

Tac
The administrator has disabled public write access.

Re: Limit Language Options on Survey List Page? 2 years 6 months ago #74226

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 248
Please add this at manual -> workarounds because this forum is cleaned up regularly and it would be a pity to loose this useful feedback.
Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Limit Language Options on Survey List Page? 2 years 6 months ago #74265

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
Is that something I can add to the wiki directly? Or should I add it as a note to the bottom of

docs.limesurvey.org/Workarounds%3A+Quest...ayout+and+templating

and someone else will add it?

I have another work-around that allows config.php to be defined in Apache's conf file, so it can be kept in a different version control system, and also allow a single limesurvey installation to support multiple domains. Where should something like that be posted?

Tac
The administrator has disabled public write access.

Re: Limit Language Options on Survey List Page? 2 years 6 months ago #74270

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5324
  • Thank you received: 294
  • Karma: 248
Please always edit the wiki directly. The comment section is the wrong place for this.

Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)limesurvey.org'"
The administrator has disabled public write access.

Re: Limit Language Options on Survey List Page? 2 years 6 months ago #74279

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
Ok, I've added that. Can someone fix the layout of that page so it's not so wide? I didn't even see that there was a login, and doing anything with that page requires a lot of horizontal scrolling. I didn't immediately see what the problem was, maybe a pre tag somewhere?

My workaround is now at

docs.limesurvey.org/Workarounds%3A+Quest...he_list_surveys_page

Thx,

Tac
The administrator has disabled public write access.

Aw: Limit Language Options on Survey List Page? 2 years 6 months ago #74288

  • Steve
  • Steve's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 494
  • Thank you received: 46
  • Karma: 17
Hello,

I'll have a look at the article. The problem seems to be the CODE parts which might get quite wide if tabs or blanks are in the CODE section.
Mit freundlichen Grüßen/Best regards,

Stefan Gohlke
LimeSurvey Team
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.271 seconds
Donation Image