English 中文(简体)
识别码——如何使用第二控制器
原标题:CodeIgniter - How to nest a view in view using second controller

因此,我认为这一部分内容是:

 <body>
    <div id = "content">
       <?php echo $catalog ?>
    </div>
 </body>

其中还有其他变量。 这里是我的主计长的一部分,我在那里把他们寄给观点:

$this->load->view( layout ,array(
         categories     =>  $categories,
         home_menu      =>  $home_menu,
         information    =>  $information,
         favourite      =>  $favourite,
         new_products   =>  $new_products,
         bestsellers    =>  $bestsellers,
         login_info     =>  $login_info,
         catalog        =>    
        ));

我想创建第二位控制器,一旦启动,就会对可变的<代码>($catalog)发出第二个看法。

与此类似(类似于Kohaana):

$this->layout->catalog = $this->load->view( products/catalog , array(
                 name           =>  $name,
                 description    =>  $description));

但它没有发挥作用。

我的问题是,在点击启动第二名主计长的链接之后,我如何表明这种第二点意见?


EDIT:

但是,在用户点击启动第二个控制器的链接后,我想将<>catalog view发送至$catalog变量。

 $products = $this->Product_model->list_products($category_id);
foreach ($products as $row)
        {
                     $name = $row->name;
                     $description = $row->description;
        }

.. after that I want $name and $description to be passed to:

$this->load->view( products/catalog , array(
                     name           =>  $name,
                     description    =>  $description));

拟通过如下案文:$catalog/code> in the layout view specified in the first controller.

问题回答

您可以称之为“$this->load->view,但我不建议采用。

取而代之的是,通过“条形形”代号,作为装货观察功能中的第3项准值,从而将这种观点重新表达,而不是重复。 之后,你可以把这部已交回的法规赋予你原意。

我希望我完全理解你的问题,但如果不是的话,我抱歉。

My guess is that you re loading the page with all of the extras and want to be able to update the content part of your page through a user initiated click.

如果你重新实施以javascript为基础的解决办法,那么你就只需要一名控制员,该控制器将产生html的碎块,并用警棍将它注入目前的网页。

如果你不执行java书,那就是一个整页的复读,那么你就只能重建该页,把选定的目录内容传送给控制员。

<>>>>>

To do this without ajax or hmvc, you need to get the contents from another controller into this controller, so you could just make an additional request with php:

$catalog_content = file_get_contents( /url_to_second_controller.html );
$this->load->view( layout ,array(
     categories     =>  $categories,
     home_menu      =>  $home_menu,
     information    =>  $information,
     favourite      =>  $favourite,
     new_products   =>  $new_products,
     bestsellers    =>  $bestsellers,
     login_info     =>  $login_info,
     catalog        =>  $catalog_content
    ));




相关问题
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 ...