Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/145251-solved-simy-benificial/
Share on other sites

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...

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?

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>

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>

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 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.