Insert a combo in menu
-
Is possible to insert a combo in menu, in place of flags ? How ?
Thanks
-
What does “combo in menu” mean?
Do you want show languages in submenu? Or ?yes in a select like this
<select>
<option value=”english”>English</option>
<option value=”italian”>Italian</option>
<option value=”spanish”>Spanish</option>
</select>Hi,
there is only one function to generate a “pseudo” combo that generate a
- list.
For you can use this code:echo '<select>'; foreach( CMLLanguage::get_all() as $lang ) { echo "<option value='$lang->cml_language_slug'>$lang->cml_language</option>"; } echo '</select>';Sorry but this code inside <?php…?> break my site
I don’t understand to put this code in right page of my theme to insert select exactly after last item of navigation menu…with plugin I choose to insert in menu and now I have flags after the last item of navigation menu. How can I insert select in the same place of it ?
PS:
1- I try to insert code in page named navigation-top and now it seems to show select, but when I choose one language is not start function and language not change….
2- Is possibible to insert only flags icon in place of text “italiano” “english” ecc…. ?
1., 2. Use this code:
echo '<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">'; foreach( CMLLanguage::get_all() as $lang ) { $img = sprintf( '<img src="%s" title="%s" alt="%s" />', CMLLanguage::get_flag_src( $result->id, $size ), $lang->cml_language, sprintf( __( '%1$ flag', 'ceceppaml' ), $result->cml_language_slug ) ); echo '<option value="' . cml_get_the_link( $lang ) . '">' . $img . '</option>"; } echo '</select>';Sorry Alessandro,
this <select onchange=”this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);”> return this url
http://www.xxxxx.it/it/portfolio/en
http://www.xxxxx.it/it/portfolio/es
http://www.xxxxx.it/it/portfolio/it
ecc…
with error 404 pagina non trovata!Then last code that you post show a syntax error in echo ‘</select>’;
Thanks so much for collaboration
There is an error in the code, this is the right one:
echo '<select onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);">'; foreach( CMLLanguage::get_all() as $lang ) { $img = sprintf( '<img src="%s" title="%s" alt="%s" />', CMLLanguage::get_flag_src( $result->id, $size ), $lang->cml_language, sprintf( __( '%1$ flag', 'ceceppaml' ), $result->cml_language_slug ) ); echo '<option value="' . cml_get_the_link( $lang ) . '">' . $img . '</option>'; } echo '</select>';Anyway I sent an email to you, let me know 🙂
The topic ‘Insert a combo in menu’ is closed to new replies.