2015-01-22 2 views
0

저는 최근 Zend Framework를 사용하는 웹 사이트에서 작업하기 시작했습니다. 웹 사이트의 플래시 메시지가 손상되었으며이를 수정해야합니다. 나는 무엇이 잘못되었는지 알아 내려고 노력해 왔으며 코드를 이해하는 데 부분적으로 성공했습니다.플래시 메신저가 메시지를 표시하지 않습니다.

이전에는 Zend Framework에서 일한 적이 없기 때문에 깨지거나 심지어 올바르게 디버깅하는 방법에 익숙하지 않았습니다.

나는 this question에 제안 된 코드를 삽입 해 보았지만 단순히 PHP를 완전히 파기했습니다.

누군가가이 코드 좀 도와 수 있다면 정말 감사하겠습니다

: 을 나는 아래의 파일이 포함됩니다 :

MrBlue_Controller_Action_Default 확장하고 다음과 같은 방식으로 플래시 MSG를 호출

LoginController.php :

{ 
        $this->_flashMessenger->addMessage(array('success', 'Done. Now get your email and confirm you account')); 
        $this->redirect('/'); 
} 

MrBlue_Controller_Action_Default는

Zend_Controller_Action에는 확장 내가 MSG를 표시 할

의 index.php :

<section class="landing-main landing-main2"> 
      <div class="landing-logo"> 
       <!-- <h1> 
        Sports Ladder <br /> 
        <span>Challenge</span> 
       </h1> 
       <div class="logo-star"> 
        &#9733; 
       </div> --> 
       <img src="http://www.sportsladderchallenge.com/img/Logo.png" alt="Sports Ladder Challenge" /> 
      </div> 
      <section class="main-highlight"> 

       <div class="join-section-right"> 
        <p class="cta-caption"> 
         Win up to <span>$50,000.00</span> 
        </p>    
        <a class="cta" href="<?php echo $this->url(array('controller'=>'login','action'=>'register'),null,true); ?>" alt="" id="signup-button" /> 
         Join Now <span>&raquo;</span> 
        </a> 
        <p class="cta-caption"> 
         It's absolutely 100% <strong>free</strong>. 
        </p> 

       </div> 
      </section> 

    <section class="sports-ladder"> 
       <?php if($this->double == 2) $d = true; else $d = false; 
      echo $this->partial('partials/ladder_sidebar.phtml',array('ladder' => $this->ladder,'safe_zones' => $this->ladder_safe, 
      'level' => $this->current_rung, 'double' => $d)); 
    ?> 

    <br /> 
    <?php 
    $oLadder = new Model_LadderObj(); 
    if(!is_null($this->current_rung) && !in_array($this->current_rung,$oLadder->getSafeZones()) && $this->current_rung!=0) : 
    ?> 
     <a class="header-buttons ladder-collect" href="<?php echo $this->url(array('action'=>'respawn-climbing'),null,true); ?>" class="btn btn-primary btn-collect" style="margin-left:16px; width:207px;" title="By pressing ‘collect’ you will have the specified dollar amount on any non-safe step (steps 5,6,8,9 etc) deposited into your account balance and forfeit the remainder of your climb. This action cannot be undone.">Collect</a> 
    <?php else : ?> 
     <a class="header-buttons ladder-collect" href="javascript:return false;" class="btn btn-default btn-collect" style="margin-left:16px; width:207px;" title="By pressing ‘collect’ you will have the specified dollar amount on any non-safe step (steps 5,6,8,9 etc) deposited into your account balance and forfeit the remainder of your climb. This action cannot be undone.">Collect</a> 
    <?php endif; ?> 
      </section> 

      <section class="main-htp"> 
       <h2> 
        How To Play 
       </h2> 
       <h4> 
        And win up to <span>$50,000.00</span>! 
       </h4> 
       <div class="htp"> 
        <div class="htp-number"> 
         1 
        </div> 
        <h3>Sign Up</h3> 

        <li> 
         Sign up, it's completely free to play! 
        </li> 
        <li> 
         Pick one of our sports match ups 
        </li> 


       </div> 
       <div class="htp"> 
        <div class="htp-number"> 
         2 
        </div> 
        <h3>Build Your Streak</h3> 
        <li> 
         Make a right pick, and climb a step 
        </li> 
        <li> 
         The higher you climb, the more money you win! 
        </li> 

       </div> 
       <div class="htp"> 
        <div class="htp-number"> 
         3 
        </div> 
        <h3>Cash Out</h3> 
        <li> 
         Earn anywhere from $0.01 to $50,000.00 per climb 
        </li> 
        <li> 
         Increase your account balance to $100 or more and cash out, it's that easy! 
        </li> 

       </div> 
      </section> 

      <section class="main-bottom-left"> 
       <h2>Start Playing Today</h2> 
       <div class="join-section-left"> 
        <div class="join-section"> 
         <p class="star">&#10097;</p> 
         <p> 
          The Sports Ladder Challenge combines the use of power ups, a wider selection of games and questions to choose from, as well as an innovative new platform that is optimized to reward users on a variety of levels to combine for the most thrilling, action packed pick em game on the web! 
         </p> 

        </div> 

        <div class="join-section"> 
         <p class="star">&#10097;</p> 
         <p> 
          We cover a wide variety of sports and leagues including the NFL, NBA, MLB, NHL, Premier League, La Liga and much more! 
         </p> 

        </div> 
        <div class="join-section"> 
         <p class="star">&#10097;</p> 
         <p> 
          There is no limit to how much you can win! Win anywhere from $0.01 to $50,000.00 on every climb. We GUARANTEE that with enough sports knowledge and due diligence, you will cash out! 
         </p> 

        </div> 
       </div> 

      </section> 
     </section> 

정말 내가 얻을 수있는 모든 도움을 주셔서 감사합니다 것

<?php if (!empty($this->messages)): ?> 
    <div style="margin-left:auto;margin-right:auto;width:90%;"> 
    <?php foreach($this->messages as $message): ?> 
     <?php if($message[0] == 'error'): ?> 
     <div class="alert alert-block alert-danger"> 
     <?php elseif($message[0] == 'success'): ?> 
     <div class="alert alert-block alert-success"> 
     <?php endif; ?> 
      <p><strong><?php echo $message[1]; ?></strong></p> 
     </div> 
    <?php endforeach; ?> 
    </div> 
<?php endif; ?> 

부분 _flash_messenger.phtml. 이 정보가 불완전한 경우 알려 주시면 추가 코드 조각을 게시하겠습니다.

업데이트 전체 코드 LoginController.php 링크에 대한 : 메시지가 더 렌더링되는 것 같습니다하지 http://codepad.org/VL4DGLtX

+0

"웹 사이트의 플래시 메시지가 깨졌습니다"는 것은 무슨 뜻입니까? 메시지가 나타나지 않거나 오류가 있습니까? 그리고 어떻게'_flash_messenger.phtml' 부분이 렌더링 되었습니까? – lku

+0

메시지가 표시되지 않고 오류가 없습니다. 나는 부분적인 것이 사용되는지조차 모른다. 페이지 상단에 인덱스 파일에 코드를 포함 시키려고했지만 이미지를 표시하는 데이 부분을 사용하는 방법을 모릅니다. 그래서 대신 나는 다른 질문에서 링크를 사용하여 코드를 시도했지만 링크도 PHP가. index.phtml 파일에서이 부분을 사용하는 방법에 대한 지침으로 나를 안내 할 수 있다면 정말 감사 할 것입니다. – Xitcod13

+0

링크 된 질문의 코드는 버전 2의 ZF 용입니다. *, 버전 1을 사용하고 있습니다. *, 그 이유는 앱을 망가 뜨 렸습니다.메시지가 렌더링되지 않은 것처럼 보입니다. 나는 별도의 답변에서 몇 가지 단서를 제공하려고 노력할 것입니다. 코드 강조 표시를 사용할 수 있습니다. – lku

답변

1

.

$this->_flashMessenger = $this->_helper->getHelper('FlashMessenger'); 
$this->view->messages = $this->_flashMessenger->getMessages(); 

이 플래시 메신저 액션 도우미 (doc)를 잡고보기 (템플릿)에 모든 메시지를 넣어 : 당신은 당신이 제공하는 추상 컨트롤러를 보면

,이 코드가있다.

이제 부분 템플릿 _flash_messenger.phtml을 원하는 위치에 렌더링해야합니다. 이를 위해 부분 뷰 도우미 (doc)를 사용할 수 있습니다.

<?php echo $this->partial('path/to/_flash_messenger.phtml', array('messages' => $this->messages)); ?> 
+0

코드 ' partial ('parcials/_flash_messenger.phtml ', array ('message '= > $ this-> messages)); ?> 'index.phtml 파일 안에? 부분로드 아래에 div를 추가 했으므로 div 부분에 txt와 txt를 추가 했으므로 부분로드를 압니다. 플래시 메시지는로드되지 않습니다. 아마도 flashMessage를 호출하는 loginController에 전체 코드를 제공 할 수 있습니다. 그것을 좁히는 데 도움이 될 것이라고 생각합니까? – Xitcod13

+0

@ Xitcod13 물론 시도해 보도록하겠습니다. – lku

+0

나는 그것을 여기 게시했다 : http://codepad.org/VL4DGLtX – Xitcod13

관련 문제