2017-12-09 1 views
-3

이 코드를 Opencart3 용 Twig 형식으로 변환해야합니다. 그러나 성공하지 못했습니다. 어떤 생각? 내가 https://php2twig.com/index.php에 있지만 오류 컨버터이 시도코드 일부를 Twig 형식으로 변환하려면 어떻게해야합니까?

<div class="col-sm-10"> 
<?php 
    $cm_count = 0; 
    $cm_count = count($cannedmessages); 
    if ($cm_count == 0) { ?> 
     Use the button to setup a new canned message 
    <?php } else { ?>      
    <select name="cannedmessage" id="cannedmessage" class="form-control"> 
     <option></option> 
     <?php foreach ($cannedmessages as $cannedmessage) { 
      if($cannedmessage['status']==1) { ?> 
       <option value="<?php echo $cannedmessage['description']; ?>"><?php echo $cannedmessage['title']; ?></option> 
      <?php } 
     } ?> 
    </select> 
<?php } ?> 
</div> 

..

<div class="col-sm-10"> 
    cm_count 0 
    cm_count count(cannedmessages) 
    {% if cm_count is 0 %} 
     Use the button to setup a new canned message 
    {% else %} 
     <select name="cannedmessage" id="cannedmessage" class="form-control"> 
     <option></option> 
     {% for cannedmessage in cannedmessages %} 
     {% if cannedmessage.status is 1 %} 
      <option value="{{ cannedmessage.description }}">{{ cannedmessage.title }}</option> 
     {% endif %} 
     {% endfor %} 

     </select> 
    {% endif %} 
    </div> 
내가 Opencart 3에 "통조림 메시지 만들기"와 함께 싸울

하지만 전투를 잃고 ...

모든
+0

을 어떤 문제가 특별히 있습니까? 코드 작성 또는 코드 변환 요청은 여기에서 주제와 관련이 없으므로 어떤 작은 문제를 해결해야하는지 보여 주어야합니다. – halfer

+0

나뭇 가지 형식을 잘못 수정했습니다. 이 부분 : "cm_count 0 cm_count count(cannedmessages) {% if cm_count is 0 %}" D. Dimitrioglo는 나를 잘 도왔습니다. 그 조정은 나를 위해 일했습니다. 도와 줘서 고마워. 알겠습니다. 온 드라. – Keo

답변

1

먼저 당신의 cannedmessagetitle 속성이 있는지 확인하고이 시도 :

{% if cannedmessages|length > 0 %} 
    <select name="cannedmessage" id="cannedmessage" class="form-control"> 
     <option></option> 
     {% for cannedmessage in cannedmessages %} 
      {% if cannedmessage.status == 1 %} 
       <option value="{{ cannedmessage.description }}">{{ cannedmessage.title }}</option> 
      {% endif %} 
     {% endfor %} 
    </select> 
{% else %} 
    Use the button to setup a new canned message 
{% endif %} 
관련 문제