Welcome Guest, Not a member yet? Register   Sign In
calling an application within an application (NOOB)
#1

[eluser]Unknown[/eluser]
Sorry noob here, I am stuck and can't seem to figure it how it works.

What i want is to have a seperate application namely nav that returns a string/links.

I want that application nav to be called by my main application layout and use its return value on the layout_view.

Ex. I have 2 applications namely

1. layout
Code:
class Layout extends Controller {

    function Layout()
    {
        parent::Controller();    
    }
    
    function index()
    {
      $this->load->library('parser');
      $data['title'] = "Title";
      $data['loadcss'] = '<link rel="stylesheet" href="{WEB_ROOT}images/styles.css" type="text/css" media="screen, projection" charset="utf-8" />';
      $data['WEB_ROOT'] = "http://localhost/CI/system/application/";
    $this->parser->parse('layout_view', $data);
    }
}

2. nav
Code:
class Nav extends Controller {

    function Nav()
    {
        parent::Controller();    
    }
    
    function index()
    {
      $this->load->library('parser');
      $data['WEB_ROOT'] = "http://localhost/CI/system/application/";
          $this->parser->parse('nav_view', $data,true);

    }
}

Layout_view code
Code:
<html>
<head>
<title>{title}</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
{loadcss}
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table id="Table_01" width="1000" height="auto" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            <img src="{WEB_ROOT}images/main_01.gif" width="341" height="149" alt=""></td>
        <td class="right_logo">
            </td>
    </tr>
    <tr>
        <td colspan="2" class="nav_bar">{nav}
            </td>
    </tr>
    <tr>
        <td colspan="2" class="content">
            </td>
    </tr>
    <tr>
        <td colspan="2" class="footer">
            </td>
    </tr>
</table>
&lt;/body&gt;
&lt;/html&gt;

nav_view code
Code:
<td>Home</td>
<td>About</td>
<td>Gallery</td>
<td>Contact</td>

How can I get the return value of the nav application and use it on my layout application then pass it on the layout view {nav} as you can see on the table class nav_bar. This is to be used for different page regions but I don't want to use any template library. What i want is different page regions have its own application.

Is this possible? Hope I made myself clear. Sorry I am really a 1 day CI noob. TIA
#2

[eluser]Pascal Kriete[/eluser]
Hey betlog,

First a little terminology. What you have here is a bunch of controllers - an application is the whole package.

Normally you can nest view loading calls, but I can't recall from the top of my head how it works for the parser. In lieu of that, the best way to go is to create a library (or in this case: a helper) to do what you need.

The use of cross-controller calls is very limited, hard to maintain, usually bad practice, and hence not included in the framework.
Generally, if more than one controller needs a piece of code it's time for a library or helper. After all, that's what they're there for.

Hope that helps and welcome to CodeIgniter.




Theme © iAndrew 2016 - Forum software by © MyBB