Php 页面标题及其标题的功能
今天我还有一个问题。我试图使我的传记页面完全可定制为我的自定义CMS项目,我正在做。如果你注意到在视图中,我有3个h2标签,分别表示报价、盟友和竞争对手。我想做的是把h3放到我的数据库中,然后让它为它们中的每一个做一个foreach循环,所以我在想我该怎么做“我必须存储与页面标题相关的函数,这样,如果页面上没有活动的函数,就不必运行它。我知道这很容易做到,但是为了完成这件事,我需要做的事情太多了。请记住,根据你在简历中的页面,会影响哪些标题可用 从现在开始,这是我的控制器:Php 页面标题及其标题的功能,php,codeigniter,Php,Codeigniter,今天我还有一个问题。我试图使我的传记页面完全可定制为我的自定义CMS项目,我正在做。如果你注意到在视图中,我有3个h2标签,分别表示报价、盟友和竞争对手。我想做的是把h3放到我的数据库中,然后让它为它们中的每一个做一个foreach循环,所以我在想我该怎么做“我必须存储与页面标题相关的函数,这样,如果页面上没有活动的函数,就不必运行它。我知道这很容易做到,但是为了完成这件事,我需要做的事情太多了。请记住,根据你在简历中的页面,会影响哪些标题可用 从现在开始,这是我的控制器: $activeTem
$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>";
}
echo“引号”;
如果(!空($quotesArray))
{
回声“”;
对于($x=0;$x报价)。“”;
}
回声“
”;
}
呼应“盟友”;
如果(!空($alliesArray))
{
回声“”;
foreach($alliesArray作为$row)
{
回显“- ”。带斜杠($row)。“
- ”;
}
回声“
”;
}
呼应“对手”;
如果(!empty($rivalsArray))
{
回声“”;
foreach($rivalsArray作为$row)
{
回显“- ”。带斜杠($row)。“
- ”;
}
回声“
”;
}
我不知道您关于存储函数的意思,也不知道您不想运行哪个函数
假设我们正在使用控制器中的最后一个else
语句
$alliesArray = $this->biomodel->getCharacterAllies($bioArray[0]->id);
$rivalsArray = $this->biomodel->getCharacterRivals($bioArray[0]->id);
$quotesArray = $this->biomodel->getCharacterQuotes($bioArray[0]->id);
。。。您“不想运行”的函数是视图中数组上的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>";
}
...
if($this->uri->segment(n)='pageIwantQuotesOn')&(!empty($quotesArray)){
呼应“引语”;
回声“”;
对于($x=0;$x报价)。“”;
}
回声“
”;
}
...