Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Display Something Based on cPath


vernman

Recommended Posts

I'm wondering if there is a way to display a banner on a page based on the cPath. I thought that a simple statement like this:

 

<?php if (CPath == "138") { echo "SOMETHING"; } ?>

 

would do the trick but it's not working. Can anyone tell me how to dispaly something based on the category link?

 

Thanks

Link to comment
Share on other sites

Try this:

 

<?php if ($cPath == 138) { echo 'SOMETHING'; } ?>

:unsure:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Then $cPath must not be set where you're using it.

 

Try this:

 

if (isset($cPath) && tep_not_null($cPath)) {
 echo 'SOMETHING';
} else {
 echo 'not set';
}

 

as a test.

 

If it displays 'not set', then there's your problem...

:-"

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

OK, I figured it out. I had it in the wrong place on the page (never gonna work in the header, before it gets called).

 

Any way, I've gotten it to work, but now I am a little perplexed. I was hoping to dispaly a special banner (now it's just the SOMING SOON text) based on the URL link:

 

http://www.vixwix.com/osc/index.php/cPath/138

 

However, the banner will also be displayed here as well:

 

http://www.vixwix.com/osc/index.php/cPath/138_174

 

How do I get it to diaply only on the top page?

Link to comment
Share on other sites

Sometimes I can be as dense as Tik wood, Vern...

:blush:

 

But, I'm not comprehending exactly what it is you're trying to do?

:unsure:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

If you would look at the following link:

 

http://www.vixwix.com/osc/index.php/cPath/138

 

You would see that this is a category called "Wholesale For Resale"

 

This link:

 

http://www.vixwix.com/osc/index.php/cPath/138_174

 

is a sub-category called "Pariffin Pillars" which is a sub-category of "Wholesale For Resale". When you setup a category you can upload an image that is 150 x 150 but the client wants to display a banner 500 x 500 ONLY on the one path. So I though the best thing to do was to look at the cPath and if that cPath = 138 then dispaly that banner. But what is happening now is that the cPath 138_174 (which is a sub-category of 138) also will dispaly that banner which is evendent when you look and see the "COMING SOON" text of each of those pages.

 

Make sense?

Link to comment
Share on other sites

Hmmmm........

:unsure:

 

The "standard link" in osC goes something like this:

 

http://www.yoursite.com/product_info.php?cPath=31&products_id=198

 

You must have an SEO mod or something that alters the links.

 

I'm fairly certain the variable $products_id is still used internally.

 

Maybe something like this would narrow it down to a particular item/product:

 

<?php if ( ($cPath == '138') && ($products_id == '174') ) {
 echo 'SOMETHING'; 
} ?>

 

This piece of code is assumning that from this link you posted:

 

http://www.vixwix.com/osc/index.php/cPath/138_174

 

And what you've said, that $cPath='138' and $products_id = '174'.

 

But, in my osC code, $products_id isn't used in index.php, only in product_listing.php, so this might not work.

 

I don't know what else to try offhand....

:wacko:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

<?php if ( ($cPath == '138') && ($products_id == '174') ) {
 echo 'SOMETHING'; 
} ?>

 

If I undertsand you correctly, what you are saying here is if $cPath is eqaul 138 AND if the $products_id is equal to 174 then echo SOMETHING. But that is not what I want. I want for it to only dispaly SOMETHING if $cPath is eqaul to 138 and the $products_id is blank which leads me to my solution:

 

 

<?php if ( ($cPath == '138') && ($products_id == '') ) {
 echo 'SOMETHING'; 
} ?>

 

Thanks!

Link to comment
Share on other sites

You mean that actually worked?

(w00t)

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

  • 4 months later...

You're welcome.

 

I must have got out of bed on the right side that day, and you did the same today.

:thumbsup:

 

:lol:

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

I think it might have been a little better, to have used;

 

<?php if ($current_category_id == 138) echo "SOMETHING"; ?>

 

rather than play with the $cPath.

 

The original poster was dealing with a $cPath which had subcategories 138_174 and as $cPath is quite inflexible it would have proved not so useful. The stuff about product_id 174 was a bit of a red herring, I think.

 

Anyway - for anyone reading this in the future, $current_category_id gives you ID of the category you are in, whatever level of subscategory (and therefore $cPath) you are...

 

Edit: Note that $current_category_id also works in other pages, such as product_info.php - so it's much more flexible than $cPath.

Link to comment
Share on other sites

For anyone reading this in the future, $cPath also works in other pages, such as product_info.php.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

For anyone reading this in the future, $cPath also works in other pages, such as product_info.php.

 

Okay, I'm completely inept, I guess. I've gotten as far as getting it to echo whatever I want based on the $cPath, but it opens up the empty product category page (I want to use this to create a Coming Soon message) and places my echoed content up in the corner of the browser window, outside of the osCommerce content.

 

Admittedly, I'm completely new to this so I may be shoving the code into the wrong spot, but I do get it to echo to the screen; just not in a usable format.

Link to comment
Share on other sites

I guess, post the code you have, and what you want it to do that it's not doing, and we'll go from there.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

I guess, post the code you have, and what you want it to do that it's not doing, and we'll go from there.

 

Okay,I'm some sort of dope. I put that same code back into index.php so that I could show you exactly where I was putting it and what was happening and this time it worked. :blink:

 

I'm guessing I had it in the wrong spot last time. Thanks.

Link to comment
Share on other sites

  • 9 months later...
Try this:

 

<?php if ($cPath == 138) { echo 'SOMETHING'; } ?>

:unsure:

 

I know this is old but it is what I need to use but I need to have

 

<?php if ($cPath == 138 or 283 or 296) { echo 'SOMETHING'; } ?>

 

how would i do this?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...