2011-11-21 4 views
0

나는 그날의 질문이 하나 더있다. 내가하고있는 내 맞춤 CMS 프로젝트에 대한 내 자서전 페이지를 완전히 사용자 정의 할 수 있도록 노력하고 있습니다. 보기에서 내가 따옴표, 동맹국, 라이벌에 대한 3 h2 태그가 있음을 알게됩니다. 내가하고 싶은 것은 h3을 내 db에 넣은 다음 각각의 하나에 대해 foreach 루프를 수행해야합니다. 그래서 어떤 방식으로 페이지 머리글과 함께 사용하는 함수를 저장해야하는지 생각하고 있습니다. 페이지에서 활성화되어 있지 않으면 실행하지 않아도됩니다.이 작업은 쉽게 수행 할 수 있지만이 작업을 완료하기 위해 수행해야하는 작업에 집중할 수있는 부분이 너무 많습니다. . 페이지는 표제를 사용할 수있는 영향을 바이오에 지금 여기로제목과 제목이있는 페이지 표제와 기능

내 컨트롤러 :

$activeTemplate = $this->sitemodel->getTemplate(); 
    $footerLinks = $this->sitemodel->getFooterNav(); 
    $bodyContent = "bio";//which view file 
    $bodyType = "main";//type of template 
    $this->data['activeTemplate'] = $activeTemplate; 
    $this->data['footerLinks']= $footerLinks; 
    $this->load->model('biomodel'); 
    if($character !== "jfkdlsjl") 
    { 
     if((!empty($character))||(!isset($character))||(trim($character) !== '')||($character !== NULL)) 
     { 
      $bioArray = $this->biomodel->getCharacterBio($character); 
      if ($bioArray == "empty") 
      { 
       $this->data['bioArray']= array(); 
      } 
      else 
      { 
       if (($bioArray[0]->characters_statuses_id == 2)||($bioArray[0]->characters_statuses_id == 3)||($bioArray[0]->characters_statuses_id == 5)) 
       { 
        $this->data['bioArray']= array(); 
       } 
       else 
       { 
        $this->data['bioArray']= $bioArray; 
        $bioPagesArray = $this->biomodel->getBioPages(); 
        $alliesArray = $this->biomodel->getCharacterAllies($bioArray[0]->id); 
        $rivalsArray = $this->biomodel->getCharacterRivals($bioArray[0]->id); 
        $quotesArray = $this->biomodel->getCharacterQuotes($bioArray[0]->id); 
        $this->data['bioPagesArray']= $bioPagesArray; 
        $this->data['alliesArray']= $alliesArray; 
        $this->data['rivalsArray']= $rivalsArray; 
        $this->data['quotesArray']= $quotesArray; 
       } 
      } 
     } 
    } 

그리고 여기 내보기입니다 :

echo "<h2>Quotes</h2>"; 
    if (!empty($quotesArray)) 
    { 
     echo "<ul>"; 
     for($x = 0; $x <= (count($quotesArray)-1); $x++) 
     { 
      echo "<li>".stripslashes($quotesArray[$x]->quote)."</li>"; 
     } 
     echo "</ul>"; 
    } 
    echo "<h2>Allies</h2>"; 
    if (!empty($alliesArray)) 
    { 
     echo "<ul>"; 
     foreach ($alliesArray as $row) 
     { 
      echo "<li>".stripslashes($row)."</li>"; 
     } 
     echo "</ul>"; 
    } 
    echo "<h2>Rivals</h2>"; 
    if (!empty($rivalsArray)) 
    { 
     echo "<ul>"; 
     foreach ($rivalsArray as $row) 
     { 
      echo "<li>".stripslashes($row)."</li>"; 
     } 
     echo "</ul>"; 
    } 

답변

1

기능을 저장하는 데 어떤 의미가 있는지, 실행하고 싶지 않은 기능이 무엇인지 알지 못합니다.

우리는 컨트롤러

$alliesArray = $this->biomodel->getCharacterAllies($bioArray[0]->id); 
$rivalsArray = $this->biomodel->getCharacterRivals($bioArray[0]->id); 
$quotesArray = $this->biomodel->getCharacterQuotes($bioArray[0]->id); 

의 마지막 else 문으로 작업하는 가정 ... 그리고 당신이 "실행하지 않으"함수가보기에서 어레이의 foreach 루프, 보기에서 논리를 처리하십시오.

if(($this->uri->segment(n)=='pageIwantQuotesOn') && (!empty($quotesArray)){ 
    echo "<h2>Quotes</h2>"; 
    echo "<ul>"; 
    for($x = 0; $x <= (count($quotesArray)-1); $x++) 
    { 
     echo "<li>".stripslashes($quotesArray[$x]->quote)."</li>"; 
    } 
    echo "</ul>"; 
} 
... 
관련 문제