Post by webpie it. » Mon Jan 31, 2011 7:42 pm

Hi Guys

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by Chones » Tue Feb 01, 2011 3:00 am

This may work - not promising though as I've not tested it ;)

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\">";
}
Of course, you will need to turn on SEO URLs and give your pages the SEO keywords about-us, contact-us etc.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by Chones » Tue Feb 01, 2011 4:03 am

Okay, have tested it now. The php you need to get the page name is the following

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);
?>
That will give $pagename the value "about-us", or "contact" etc.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by webpie it. » Tue Feb 01, 2011 7:58 pm

Hi Craig

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by Chones » Wed Feb 02, 2011 2:43 am

Hi Chris,

You should try this

Code: Select all

echo "<body style=\"background: url('../image/backgrounds/background1.jpg')\">";
Hope that works.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by webpie it. » Sat Feb 05, 2011 6:10 pm

Hi Craig

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by webpie it. » Sat Feb 05, 2011 6:14 pm

Just to let you know, i have tried the following method on the page:

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by Chones » Sat Feb 05, 2011 7:06 pm

No worries. You have this showing up at the top of the page: if ($pagename == "aboutus") { echo ""

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\">";
}
?>
Weird that you have no htaccess file, it should be in the upload directory and loaded up to the root directory of your site - save the following as .htaccess.txt and load it up then rename it to .htaccess - You'll see I've changed RewriteBase / to RewriteBase /onevintagestore/ - That should sort your problems

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by webpie it. » Mon Feb 07, 2011 4:25 am

I will try this first thing tomorrow, Craig your help is greatly appreciated, and time you are giving to my problems.

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by webpie it. » Mon Feb 07, 2011 8:49 pm

Hi craig

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by webpie it. » Mon Feb 07, 2011 8:49 pm

Hi craig

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by Chones » Tue Feb 08, 2011 7:30 am

Hi 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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by webpie it. » Tue Feb 08, 2011 4:45 pm

Hi craig

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by webpie it. » Tue Feb 08, 2011 6:13 pm

I've found out the mod_rewrite is enabled.

So I'm now not sure why this isn't working.

Regards

Chris


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by Chones » Wed Feb 09, 2011 7:45 am

Sorry, but servers aren't my area I'm afraid. Maybe start a new topic - "SEO URLs not working with my server set up" or something.

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


User avatar
Active Member

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by webpie it. » Thu Feb 10, 2011 4:06 pm

Thanks Craig, I've Done That.

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


Active Member

Posts

Joined
Mon Jan 31, 2011 7:28 pm

Post by budalal » Tue May 24, 2011 11:53 pm

Hi,

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

New member

Posts

Joined
Sun Oct 24, 2010 2:05 pm

Post by budalal » Wed May 25, 2011 12:21 am

Hi guys,

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);
Then do something like this:

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')\">";
};
?>
hope you find it useful! :)

Regards.

OC version 1.4.9.1

New member

Posts

Joined
Sun Oct 24, 2010 2:05 pm

Post by Pobb » Tue May 31, 2011 2:50 pm

Hello, I've been trying to get different styles for different pages to work but with limited success.

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 } ?>  
The issue I'm facing is that the CSS is only applied to the 1st two levels (parent category & sub-category) but not the third which is the product page.

I'm a bit of a dunce with php and would greatly appreciate some help.

Active Member

Posts

Joined
Tue May 31, 2011 2:35 pm

Post by michal777 » Tue Jul 05, 2011 7:22 pm

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

Newbie

Posts

Joined
Sun Jun 05, 2011 2:42 am
Who is online

Users browsing this forum: No registered users and 31 guests