pbrad
Posts: 58
|
| Posted: 08/08/2008, 8:42 AM |
|
Hi,
I am having a problem with images in Include pages when the parent page resides within a sub-folder of the site root.
For example, I have an include page called Header in the site root and all is fine. Now, I want to add a folder called Store but use the same Header as the root level site pages. I have tried playing around with the relative path of the images in the Header page (Images, /Images, ./Images, ../Images etc..) but the images either show up in the root level pages or the Sub-level pages but not both.
Any suggestions?
Thanks,
Pete
_________________
Pete
CCS 4
MySQL
PHP |
 |
 |
Oper
Posts: 1195
|
| Posted: 08/08/2008, 8:51 AM |
|
you could use a absolut path from the web root like
/WebPage..../Image/yourimage.gif
_________________
____________________________
http://www.7bz.com (Free CMS,CRM Developed in CCS)
http://www.PremiumWebTemplate.com
Affiliation Web Site Templates
Please do backup first |
 |
 |
pbrad
Posts: 58
|
| Posted: 08/08/2008, 9:11 AM |
|
Thanks for the suggestion. If I put the path of the image as "http://localhost/ProjectName/Images/ImageName.jpg" it works fine locally but won't work on the server. If I put the domain name in the path, it will work on the server but I won't be able to test locally as I develop the app.
Is there any trick to allow for the visibility of images on both servers without having to change all the image paths every time that you publish the site to Server2? I noticed in the help file a reference to a PathToRoot variable and am wondering if I can incorporate this somehow.
Pete
_________________
Pete
CCS 4
MySQL
PHP |
 |
 |
Waspman
Posts: 948
|
| Posted: 08/08/2008, 9:59 AM |
|
Try creating a variable in the second page which is added to the path.
field value = path1 + Field name
If the variable isn't set it won't make a difference.
Set it when the level 2 page is open and it gets added the path in the header.
?
T
_________________
http://www.waspmedia.co.uk |
 |
 |
datadoit
|
| Posted: 08/08/2008, 10:54 AM |
|
You could fiddle around with the absolute path like such:
if ($_SERVER['HTTP_HOST'] == "127.0.0.1" || $_SERVER['HTTP_HOST'] ==
"localhost") {
$path = "http://" . $_SERVER['HTTP_HOST'] .
substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'],
'/images/') + 1);
}
else {
$path = "http://" . $_SERVER['HTTP_HOST'] . "/images/";
}
|
|
|
 |
pbrad
Posts: 58
|
| Posted: 08/08/2008, 11:37 AM |
|
Hi Tony,
I think that the variable may be the way to go. Could you please give me a quick hand with the code?
I put a Declare Variable action on 'After Initialize' in a test page that is in a subfolder:
//Declare Variable @3-048DCE11
global $rootpath;
$rootpath = '../';
//End Declare Variable
and then put: "background="{rootpath}Images/B4You-bkgd.gif" border="0">" in the html of the header include page.
It isn't capturing the variable, am I way off base?
Thanks,
Pete
_________________
Pete
CCS 4
MySQL
PHP |
 |
 |
Waspman
Posts: 948
|
| Posted: 08/08/2008, 12:54 PM |
|
I would put the path in a hidden field...
$container->hiddenpatheholder->SetVaue("../")
then...
<body background="{hiddenpathholder}image.jpg" boarder="0">
will work.
T
_________________
http://www.waspmedia.co.uk |
 |
 |
pbrad
Posts: 58
|
| Posted: 08/09/2008, 4:58 AM |
|
Thanks for the help guys, I finally got it working.
In the folder and sub-folder pages I put the following code in a before show event:
global $Tpl;
$Tpl->SetVar("pathroot", "../");
or
global $Tpl;
$Tpl->SetVar("pathroot", "./"); (Depending on the level of the page in the site structure)
And in the html of the Includable 'Header' page I put:
background="{pathroot}Images/filename.jpg"
We are now one step closer to easily dropping in functional modules into the CodechargeCMS Project.
Cheers,
Pete
_________________
Pete
CCS 4
MySQL
PHP |
 |
 |