Last active
December 19, 2015 12:29
-
-
Save putzflorian/5955606 to your computer and use it in GitHub Desktop.
Countrydropdown preselected list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if($this->editmode){ ?> | |
| <?= $this->translate('Auswahl') ?>: | |
| <?php echo $this->select("mymode",array( | |
| "store" => array( | |
| array("myselect", $this->translate('Länder vorselektierung')), | |
| array("myauswahl", $this->translate('Länder auswählen')) | |
| ),"reload" => true | |
| )); ?> | |
| <?php | |
| $countries = \Zend_Locale::getTranslationList('Territory', $this->language, 2); | |
| asort($countries); | |
| $newcountries = array(); | |
| foreach($countries as $key => $value){ | |
| $newcountries[] = array($value, $value); | |
| } | |
| ?> | |
| <?php if($this->select("mymode")->text == 'myselect'){ ?> | |
| <h2><?= $this->translate('Länder vorselektierung') ?></h2> | |
| <?php while($this->block("contentblock")->loop()) { ?> | |
| <?php echo $this->select("mySelect",array( | |
| "store" => $newcountries, | |
| "width" => 500 | |
| )); ?> | |
| <?php } ?> | |
| <?php } else { ?> | |
| <h2><?= $this->translate('Länder auswählen') ?></h2> | |
| <?php while($this->block("contentblock")->loop()) { ?> | |
| <?php echo $this->select("mySelect",array( | |
| "store" => $newcountries, | |
| "width" => 500 | |
| )); ?> | |
| <?php } ?> | |
| <?php } ?> | |
| <?php } else { ?> | |
| <option value="">-- <?= $this->translate('bitte wählen') ?> --</option> | |
| <?php if($this->select("mymode")->text == 'myselect'){ ?> | |
| <?php | |
| $bottomcountries = \Zend_Locale::getTranslationList('Territory', $this->language, 2); | |
| asort($bottomcountries); | |
| $top = array(); | |
| while($this->block("contentblock")->loop()) { | |
| $top[] = $this->select("mySelect")->text; | |
| } | |
| $result = array_diff($bottomcountries, $top); | |
| $all = array_merge($top, $result); | |
| ?> | |
| <?php } else { ?> | |
| <?php | |
| $all = array(); | |
| while($this->block("contentblock")->loop()) { | |
| $all[] = $this->select("mySelect")->text; | |
| } | |
| ?> | |
| <?php } ?> | |
| <?php foreach ($all as $value){ ?> | |
| <option value="<?= $value ?>"><?= $value ?></option> | |
| <?php } ?> | |
| <?php } ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add namespaces & translations