Welcome Guest, Not a member yet? Register   Sign In
Best way to avoid duplicating html in views
#5

[eluser]nhm tanveer hossain khan (hasan)[/eluser]
hi,
we have solved this problem on our project without using any other libraries.
we kept "templates" directory under views. where we are keeping layout related design.

check out our base-template-1.php which is used for rendering the common layout.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
  &lt;?= $this->load->view('common/top_header') ?&gt;
  &lt;body&gt;
    <div id="wrapper" >
      <div id="masthead">
        <div class="logo"></div>
        <div class="headcont">
          &lt;?= alt_site_url() ?&gt;
          &lt;?= $this->load->view('common/menu') ?&gt;
        </div>
        &lt;!-- END: headcont --&gt;
        <div class="seperater"></div>
      </div>
      &lt;!-- END: masthead --&gt;

      &lt;!-- loading status panel --&gt;
      &lt;?= $this->load-view("common/message") ?&gt;

      &lt;? if (is_authenticated() && !isset($no_activity_update_panel)): ?&gt;
        &lt;?= $this->load->view('.... some other stuffs ....') ?&gt;
      &lt;? endif; ?&gt;

      &lt;!-- base content area --&gt;
      <div id="content">
        &lt;? if (!empty($content_src)): ?&gt;
          &lt;?= $this->load->view($content_src); ?&gt;
        &lt;? endif; ?&gt;
      </div>
      &lt;!-- ends base content area --&gt;
    </div>
  
   &lt;? $this->load->view('common/analytics')?&gt;
  &lt;/body&gt;
&lt;/html&gt;

example usages from the controller action -
Code:
// send view the list of retrieved result
    $data = array(
      "items" => $items,
      "content_src" => "search/index"
    );

    // render search result
    $this->load->view("templates/base-template-1", $data);

hope that would help.

best wishes Smile


Messages In This Thread
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:50 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 09:31 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:24 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:35 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 10:46 AM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 01:10 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 01:27 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 05:44 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:24 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:24 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 06:54 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:04 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:13 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:18 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:19 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:26 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:27 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:29 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:30 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:32 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 08:42 PM
Best way to avoid duplicating html in views - by El Forum - 12-18-2008, 09:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB