blueman378 Posted February 15, 2009 Share Posted February 15, 2009 hi guys, well ive got a script which defines a whole pile of variables,functions ect, then at the end of it it includes the html part of the code, so index.php->includes->Themes/index.php. now im wondering how can i make it so if say i open the Themes/index.php it can still read the stylesheet but when i include it in the base index.php and view it in the browser it can still access it? this is the same thing with images ect. i dont want to have to everytime i want to view the theme by itself go through and change all the links, any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/ Share on other sites More sharing options...
AV1611 Posted February 15, 2009 Share Posted February 15, 2009 hi guys, well ive got a script which defines a whole pile of variables,functions ect, then at the end of it it includes the html part of the code, so index.php->includes->Themes/index.php. now im wondering how can i make it so if say i open the Themes/index.php it can still read the stylesheet but when i include it in the base index.php and view it in the browser it can still access it? this is the same thing with images ect. i dont want to have to everytime i want to view the theme by itself go through and change all the links, any ideas? Um... without some code, I got no idea what you want... Quote Link to comment https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/#findComment-762491 Share on other sites More sharing options...
blueman378 Posted February 15, 2009 Author Share Posted February 15, 2009 ok well basically my directory structure is this ROOT -Forum --Index.php ---Themes ----Default -----Index.php -----style.css -----Images ------Some images here now in the first index.php id be looking at having something like: <?php $pagename = "Homepage"; function loopecho($start,$finish); { while($start <= $finish) { echo $start; $start++; } } include("Themes/default/index.php"); ?> obviously that is a very simple example then in the second index.php (under themes/default) i would have osmething like <html> <head> <!-- CSS Stylesheet --> <link rel="stylesheet" type="text/css" href="style.css" /> <!-- / CSS Stylesheet --> <title><?php echo $pagetitle; ?></title> </head> <body> <div class="id1"> <img src="images/header.png"> <?php loopecho("1","45"); ?> </div> </body> does that get across what im trying to do? the speration of logic from code (without any frameworks) now obviously this wont work as it owuld look for the img it owuld be ROOT/forum/images/header.png same sort of problem for the style sheet. but if i code into the html for it to look in the right place for the images and stylesheet then i can only edit it live. so is there any way to when its executed from the server change the path it looks in for things, and when its not use what it reads as? Quote Link to comment https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/#findComment-762500 Share on other sites More sharing options...
Philip Posted February 15, 2009 Share Posted February 15, 2009 Something like this? <?php $pagename = "Homepage"; define(THEME_PATH,'Themes/default/'); function loopecho($start,$finish); { while($start <= $finish) { echo $start; $start++; } } include(THEME_PATH.'index.php'); ?> <html> <head> <!-- CSS Stylesheet --> <link rel="stylesheet" type="text/css" href="style.css" /> <!-- / CSS Stylesheet --> <title><?php echo $pagetitle; ?></title> </head> <body> <div class="id1"> <img src="<?php echo THEME_PATH; ?>images/header.png"> <?php loopecho("1","45"); ?> </div> </body> Quote Link to comment https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/#findComment-762507 Share on other sites More sharing options...
blueman378 Posted February 15, 2009 Author Share Posted February 15, 2009 yeah i thought of doing that, only problem is that then if i dont access it throught the server it literally tries to look in "<?php echo THEME_PATH; ?>images/header.png", im thinking there is no real way around this? Quote Link to comment https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/#findComment-762508 Share on other sites More sharing options...
Philip Posted February 15, 2009 Share Posted February 15, 2009 So, in the second code: <?php if(!defined(THEME_PATH)) define(THEME_PATH, ''); ?> <html> <head> <!-- CSS Stylesheet --> <link rel="stylesheet" type="text/css" href="style.css" /> <!-- / CSS Stylesheet --> <title><?php echo $pagetitle; ?></title> </head> <body> <div class="id1"> <img src="<?php echo THEME_PATH; ?>images/header.png"> <?php loopecho("1","45"); ?> </div> </body> Quote Link to comment https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/#findComment-762510 Share on other sites More sharing options...
blueman378 Posted February 15, 2009 Author Share Posted February 15, 2009 i was thinking possibly grab the output of the page and then replace src=" with src="Themes/default ? this is more for editing the page when NOT going througgh the server, so i/theme creators dont have to keep replacing the links. Quote Link to comment https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/#findComment-762512 Share on other sites More sharing options...
Philip Posted February 15, 2009 Share Posted February 15, 2009 i was thinking possibly grab the output of the page and then replace src=" with src="Themes/default ? this is more for editing the page when NOT going througgh the server, so i/theme creators dont have to keep replacing the links. I'm confused on what you mean. Adding: <?php if(!defined(THEME_PATH)) define(THEME_PATH, ''); ?>/ at the top of the theme pages, would allow for you to view the page on its own without the Themes/default Quote Link to comment https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/#findComment-762514 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.