about "switch" MB view

Support MB Views about "switch" MB view

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #48868
    369cycle369cycle
    Participant

    The current syntax is running normally. Is there a way to write it similar to "switch"? If I add more, I am worried that the performance will be poor.

    {% if post.one_show.value == 'album' %}
        {% include 'one_album' %}
    {% elseif post.one_show.value == 'download' %}
        {% include 'one_download' %}
    {% elseif post.one_show.value == 'faq' %}
        {% include 'one_faq' %}
    {% elseif post.one_show.value == 'video' %}
        {% include 'one_video' %}
    {% elseif post.one_show.value == 'link' %}
        {% include 'one_link' %}
    {% elseif post.one_show.value == 'area' %}
        {% include 'one_area' %}
    {% else %}
        <p>沒有設置任何功能</p>
    {% endif %}
    
    #48876
    PeterPeter
    Moderator

    Hello,

    Twig template engine doesn't support the switch statement as PHP. You can use the if else code as you do in your code. Refer to Twig documentation https://twig.symfony.com/doc/3.x/tags/index.html

    And please note: we don't support the customization code for your specific needs. Please read more about our support policy here https://support.metabox.io/topic/support-policy/

    Thank you.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.