Hello again,
I use a class to help me with the layout of my homepage. To the left I have buttons that redirect to various php script (pages). Those are displayed in the main column on my page.
The mainpage class is stored in Framework_Lib.php and before I had all the pages in the same folder as Framework_Lib.php and it all worked fine.
The problem is there are so many files now so I wanted to move the pages the buttons point to to a subfolder called Leftmenu.
Now it only works the first time I click a button but after that all the links are broken since i jump from /Main folder (where the class is stored) to /Main/Leftmenu/
The way the page is setup is i make an array with the buttons and the url like $buttons = array ("Show Users" => "/../Main/Leftmenu/users.php");
In users I use
ob_start();
Code here
$content=ob_get_contents();
ob_end_clean();
$homepage->content = $content;
$homepage->Display();
So it all works fine when all the content is in the same folder but as soon as i put stuff in another folder it ofcourse breaks since my button array redirect to another folder.. but is there a way to get back to redirect back to the Main folder from the users.php page?
How to change directory when using a classtemplate
Moderator: General Moderators
Re: How to change directory when using a classtemplate
Is your Framework_Lib basically just doing an include of that page? You could set a variable as a base path so you can load things relative to its location. Really, though, feels like there's some reinventing of the wheel going on here. Any reason you're not using an existing router and something like Twig for templating?
Re: How to change directory when using a classtemplate
The browser won't go into the Leftmenu "directory" unless you tell it to in a link.
Re: How to change directory when using a classtemplate
Yeah. The Framework_lib just defines the layout and a row with top buttons and leftside buttons and what background imges to use in the different divs.Is your Framework_Lib basically just doing an include of that page?
I like wheelsReally, though, feels like there's some reinventing of the wheel going on here.
Well I want to learn and know what Im doing, also havent heard bout Twig before. But my template work fine if i just leave the files in the same folder. Was just curious if there were an easy fix like chdir() or something to jump back.Any reason you're not using an existing router and something like Twig for templating?
I do tell it to go there in the buttons array.. Was curious if there were any easy way to go backThe browser won't go into the Leftmenu "directory" unless you tell it to in a link.
Re: How to change directory when using a classtemplate
$root = realpath($_SERVER["HTTP_HOST"]);
Think that solved my problem...atleast with the links but now my graphics is screwed up... Fix 1 thing and break 2 other things heh
Think that solved my problem...atleast with the links but now my graphics is screwed up... Fix 1 thing and break 2 other things heh
Re: How to change directory when using a classtemplate
Have you tried what I suggested earlier? Define your templates path in and relative to your Framework_Lib and use that to get the full path to use in your includes, rather than trying to juggle relative paths.
Re: How to change directory when using a classtemplate
I have some systems in earlier catalogues than the framework so I used $root = realpath($_SERVER["HTTP_HOST"]);
and $root = realpath($_SERVER["DOCUMENT_ROOT"]); instead and it worked like a charm.
Reason the graphics ddnt work was i forgot to update the img path but now it all works again
Thanks
and $root = realpath($_SERVER["DOCUMENT_ROOT"]); instead and it worked like a charm.
Reason the graphics ddnt work was i forgot to update the img path but now it all works again
Thanks