New here, so i'll try and explain my problem as clearly as possible.
The site i'm developing is:
http://www.onevintagedesigns.com/onevintagestore/
I decided to use Open cart, becuase i trued so many others and i think this is the best for clarity.
Basically i have a few things i'm looking to do but i'll just start with the first one.
At the moment the background is white, i am looking to have a different image on each page such as:
About us
Contact
Brands We Stock
The:
Shop
Account
Order process
etc...
will just keep the white background to keep things simple for the customer.
I have a look around at this problem and other people asking similar questions but no process has been explained fully in detail and SETP BY STEP as mu coding with PHP is a at novice stadards.
Would anyone like to suggest a method I can do this by in a step by step format?
Thanks Everyone
(Hope I posted this under the right category)
Regards
Chris
You need to get the page name first using PHP - possible solution here if you scroll down:
http://www.webcheatsheet.com/PHP/get_cu ... ge_url.php
Run that before your <body> tag in your header and store the result as $pagename
Delete the body tag and run a routine to output the body tag with a background. Something like
Code: Select all
if ($pagename == "about-us") {
echo "<body style=\"background: your background here\">";
} elseif ($pagename == "contact-us") {
echo "<body style=\"background: your other background here\">";
} else {
echo "<body style=\"background: your default background here\">";
}
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
Code: Select all
<?php
$isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on");
$port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443")));
$port = ($port) ? ':'.$_SERVER["SERVER_PORT"] : '';
$url = ($isHTTPS ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$port.$_SERVER["REQUEST_URI"];
$pagearray = explode("/", $url);
$pagename = end($pagearray);
?>
You can then use the second part to output the <body> tag. Just use "contact" not "contact-us", my bad
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
Thanks for the reply and the test can't thank you enough for replying.
I was wondering if you could just break it down a bit further for me.
What i mean if you could show me an example.
The images i want to use are i the directory "../image/backgrounds/....." (this is just so you could insert an example path).
Hope thats ok
Chris
Regards
Chris
You should try this
Code: Select all
echo "<body style=\"background: url('../image/backgrounds/background1.jpg')\">";
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
Sorry for the late reply, my lifes been a bit crazy lately.
I know I suck on the subject we have been discussing, and i'm still having problems.
You don't jave to do this if its getting annoying but everything you have described above i was hoping you could just do a step by step guide because i'm finding it hard STILL to understand.
(before asking this i have tried so many times but failed, and your my last hope really)
Many thanks
Chris
Regards
Chris
ABOUT US
if you go on that page you will see that the page can not be found, this only happens when I turn on seo friendly URLS in admin.
The opencart download I had did not have htaccess.txt file to change to a .htaccess file, is something to do with it?
SORRY
Regards
Chris
This is because you didn't wrap the first part of the code in PHP tags. It should be:
Code: Select all
<?php
if ($pagename == "about-us") {
echo "<body style=\"background: your background here\">";
} elseif ($pagename == "contact") {
echo "<body style=\"background: your other background here\">";
} else {
echo "<body style=\"background: your default background here\">";
}
?>
Code: Select all
# 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
# 2. In your opencart directory rename htaccess.txt to .htaccess
# For any support issues please visit: http://www.opencart.com
Options +FollowSymlinks
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini)">
Order deny,allow
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
RewriteBase /onevintagestore/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling, then restore the # as this means your host doesn't allow that.
# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
I will let you know first thing after I have tried your method, and you'll be able to see it to.
Thanks Again Craig
Chris
p.s Forgot to say I will make sure I buy you a beer on your site
Regards
Chris
Sorry to bother you.
Ok so I've wrapped the php code correctly, not getting any errors from that.
copied the htaccess info to htaccess.txt, uploaded it to the root, and changed it to .htaccess.
I get this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@onevintagedesigns.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Which I've seen before in the past, but becuase of my lack knowledge with the rewrite, not sure how to solve it.
http://www.onevintagedesigns.com/onevintagestore
I've left the error on there for you to see.
Hope you can help me solve this problem, (me and my crazy ideas, ay, I said to myself this would be easy too).
Chris
Regards
Chris
Sorry to bother you.
Ok so I've wrapped the php code correctly, not getting any errors from that.
copied the htaccess info to htaccess.txt, uploaded it to the root, and changed it to .htaccess.
I get this error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@onevintagedesigns.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Which I've seen before in the past, but becuase of my lack knowledge with the rewrite, not sure how to solve it.
http://www.onevintagedesigns.com/onevintagestore
I've left the error on there for you to see.
Hope you can help me solve this problem, (me and my crazy ideas, ay, I said to myself this would be easy too).
Chris
Regards
Chris
You should probably contact your host and ask if they have mod_rewrite enabled. And you need to be on an apache server (but most are).
Yours,
Craig
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
It's my own server:
I used this to see if it was installed:
http://onevintagedesigns.com/test/test.php
I can't see it, but it is an Apache server.
I've looked online to find the file:
httpd.conf file
I am using WHM(web host manager) but I just can't find the directory and the online help just does not make sense?
Any ideas?
Chris
Regards
Chris
So I'm now not sure why this isn't working.
Regards
Chris
http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk
http://www.onevintagedesigns.com/onevintagestore/
Just on a side point you'll notice on the site that i've styled the menu bar pink etc...
Above that in the top right hand corner you'll notice i've duplicated:
Contact account shopping cart checkout
I'm looking to take out the:
account shopping cart checkout
fro the pink menu as I know have it above it and replace these with other links.
I've tried removing these from the pink menu having duplicated them above, but when i do the code breaks,any thoughts as to why.
I mean I would understand if I hadn't duplicated them above, but because there is effectively the same menu above the pink one, I thought it would let me remove these.
Any thoughts
Chris
Regards
Chris
Great job guys, works beautifully. Quick query. Is there a way to also check for the parent category and assign the same color, background, etc? For example, I have a Clothing category, with clothing, bags, and so on. The only thing I can think of is to make a conditional if-or statement:
<?php if ($pagename == "clothing-accessories") || ($pagename == "bags")... {
echo "<body style=\"background-color:purple\">";
}
This will be a pain if you have loads of subcats!
Thanks
OC V. 1.4.9.1
I guess when the going gets tough, get to coding!
I Managed to do it an want to share it with all of you in case you want to apply it as well:
add the following to the php code that detects the page name:
Code: Select all
$pagearray2 = explode("/", $url);
$pagename2 = end($pagearray2);
$pagename2 = prev($pagearray2);
Code: Select all
<?php if ($pagename == "clothing-accessories" || $pagename2 == "clothing-accessories") {
echo "<body style=\"background-color:purple\">";
} elseif ($pagename == "furniture" || $pagename2 == "furniture" ) {
} else {
echo "<body style=\"background:url('image/page_bg_img.jpg')\">";
};
?>
Regards.
OC version 1.4.9.1
I have three categories - Evening Wear, Resort Wear & Accessories. The first utilises the default CSS, no probs there. The other two need to use a different CSS. So far I have the following in my header:
Code: Select all
<?php
$isHTTPS = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on");
$port = (isset($_SERVER["SERVER_PORT"]) && ((!$isHTTPS && $_SERVER["SERVER_PORT"] != "80") || ($isHTTPS && $_SERVER["SERVER_PORT"] != "443")));
$port = ($port) ? ':'.$_SERVER["SERVER_PORT"] : '';
$url = ($isHTTPS ? 'https://' : 'http://').$_SERVER["SERVER_NAME"].$port.$_SERVER["REQUEST_URI"];
$pagearray = explode("/", $url);
$pagename = end($pagearray);
$pagearray2 = explode("/", $url);
$pagename2 = end($pagearray2);
$pagename2 = prev($pagearray2);
?>
<?php
if ($pagename == 'resort-wear' || $pagename2 == "resort-wear") { ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/resort-access.css" />
<?php
} elseif ($pagename == 'accessories' || $pagename2 == 'accessories') { ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/resort-access.css" />
<?php
} else { ?>
<link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/stylesheet.css" />
<?php } ?>
I'm a bit of a dunce with php and would greatly appreciate some help.
I'm trying to do something similar but only with home page
The problem is
1. it only works whit link like this http://demo.opencart.com/index.php?route=common/home
containing ../index.php?route=common/home
2. it doesn't work with link http://demo.opencart.com
Thank you for your time!
Users browsing this forum: No registered users and 31 guests