Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Alessandro Senese

    (@ceceppa)

    What does “combo in menu” mean?
    Do you want show languages in submenu? Or ?

    Thread Starter symop

    (@symop)

    yes in a select like this

    <select>
    <option value=”english”>English</option>
    <option value=”italian”>Italian</option>
    <option value=”spanish”>Spanish</option>
    </select>

    Plugin Author Alessandro Senese

    (@ceceppa)

    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>';
    Thread Starter symop

    (@symop)

    Sorry but this code inside <?php…?> break my site

    Thread Starter symop

    (@symop)

    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…. ?

    Plugin Author Alessandro Senese

    (@ceceppa)

    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>';
    Thread Starter symop

    (@symop)

    Sorry Alessandro,
    this <select onchange=”this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);”> return this url
    https://www.xxxxx.it/it/portfolio/en
    https://www.xxxxx.it/it/portfolio/es
    https://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

    Plugin Author Alessandro Senese

    (@ceceppa)

    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 ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Insert a combo in menu’ is closed to new replies.