Welcome Guest, Not a member yet? Register   Sign In
E-shop, best way!
#11

[eluser]Buso[/eluser]
[quote author="überfuzz" date="1258166833"][quote author="Buso" date="1258151697"]
and this goes inside a function in your controller:
Code:
// INITIALIZATIONS (layout data)
$data['doctype'] = "";
$data['head']    = "";
$data['header']  = "";
$data['content'] = "";
$data['sidebar'] = "";
$data['footer']  = "";
    
// PAGE DATA (views data)
$user = $this->usersmodel->getUser();
$header_data['user']          = $user;
$comments_data['user']        = $user;
    
// PAGE STRUCTURE (views)
$data['doctype'] = doctype('xhtml1-trans');
$data['head']    = "";
$data['header']  = $this->load->view('header',$header_data,true);
$data['content'] = $this->load->view('form_comments',$comments_data,true)
                 . $this->load->view('comments','',true);
$data['sidebar'] = $this->load->view('sidebar','',true);
$data['footer']  = $this->load->view('footer','',true);
    
// PAGE -> RENDER VIEW (layout)
$this->load->view('layout',$data);

i think its self-explanatory (just take what you need from it)[/quote]

Most of that you could store in the config file?[/quote]
?
Im loading the views, which are different for each page
Don't know what you mean
#12

[eluser]WebbHelp[/eluser]
Maybe
I don't know what the code does... I thought I knew but maybe not.
I want that when you click on a link and you get to a adress like this: ?p=contact.
Then I want different information/a page will shos up.

So, if you are on page start(?p=start) then you click on a link and get to ?p=contact, then the contact page will shows up.

The things is that I don't want to have like 5 pages with the layout code, HTML and CSS because I want like this:

<div id="all">

<div id="content">

if($_GET['p'] == 'start')
{
include('start.php');
}

if($_GET['p'] == 'contact')
{
include('contact.php');
}
</div>

</div>

You see I include the page I want to show.
How can I do this with CodeIgniter?

That's my question Smile
#13

[eluser]Buso[/eluser]
[quote author="webbhelp" date="1258379222"]Maybe
I don't know what the code does... I thought I knew but maybe not.
I want that when you click on a link and you get to a adress like this: ?p=contact.
Then I want different information/a page will shos up.

So, if you are on page start(?p=start) then you click on a link and get to ?p=contact, then the contact page will shows up.

The things is that I don't want to have like 5 pages with the layout code, HTML and CSS because I want like this:

<div id="all">

<div id="content">

if($_GET['p'] == 'start')
{
include('start.php');
}

if($_GET['p'] == 'contact')
{
include('contact.php');
}
</div>

</div>

You see I include the page I want to show.
How can I do this with CodeIgniter?

That's my question Smile[/quote]
you should read the userguide

in codeIgniter you can use urls like this:

yourdomain.com/controller/function/parameter

so, depending on which controller or functions or parameters you send via url, you can show different views.

no need to use ugly urls like ?var=value&var2=value&etc;
#14

[eluser]WebbHelp[/eluser]
No of course I wouldn't use ?p=page Tongue
But it was an example Smile

Yes, but how should I do to make it easy for me, so I only need to "write" the layoutcode on one page and then "include" or something.

So... If I need to change one thing in the layout I only do it in one page, the "layout page".

Thanks
#15

[eluser]WebbHelp[/eluser]
Somebody?
Really need to know this Smile
#16

[eluser]eokorie[/eluser]
I think you may need to look at the uri class documentation. You could probably use something like:

Code:
$page = $this->uri->segment(n); //n being the segment you are trying to get

if ($page == "start") {
    // Do Something Here....
}

Don't know if that helps..
#17

[eluser]WebbHelp[/eluser]
Thanks, I now about that, but if... we say that $page is "start", then shall som info shows for startpage.
But if I click on a link now and get to contact.

Should I check on the constructor function that runs directly when page loads, if($page == "contact") and If it is contact I run another function that fills $data['headertext'] , $data['contenttext'] with the text that will shows on contact?

Or how shall I do?

Thanks //WebbHelp




Theme © iAndrew 2016 - Forum software by © MyBB