English 中文(简体)
模板
原标题:Template Building
最佳回答

如果我理解正确的话,你想要把一个头脑和脚步联系起来吗?

我也存在同样的问题,最后提出利用图书馆来做这项工作的想法。

What I did was create a filelibraries/render.php with something like:

class render
{
    private $CI;
    function __construct ()
    {
        parent::__construct();
        $this->CI &= get_instance();
    }
    function view ($activeView, $params, $title)
    {
        $this->CI->load->view( template/header.php , array( title =>$title));
        $this->CI->load->view($activeView, $params);
        $this->CI->load->view( template/footer.php , array( navbar =>$this->RenderFooterNavBar()));
    }

    private function RenderFooterNavBar ()
    {
        $bits = array( Home , About Us ,  Contact ); //You could get these from anywhere
        return $this->CI->load->view( template/modules/footernavbar , array( bits =>$bits), TRUE); //returns the rendered output of that view
    }
}

With the files like:
template/header.php:

<html>
<head>
    <title><?php echo $title; ?></title>
</head>
<body>

template/footer.php:

</body>
</html>

<ul>
<?php
foreach ($bits as $item)
    echo "<li>$item</li>";
?>
</ul>

然后使用:

function index ()
{
    $this->render->view( post , $data,  Blog Post );
}

请注意,这应当与任何排位制度合作,只打上上载荷->view与你的排位制度相适应。 如果你想从一个数据库中提取物品,这同样是使数据达到顶头/脚步需要的重要途径,这只是反映了我与“功能”所做的那样。

Hope that helps some,
Max

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签