Jump to content

Archived

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

olimits7

Beginner - Help with small change in code?

Recommended Posts

Hello,

I have this case statement in my code that I would like to change, so it applies to a specific category path number, but I don't know what I have to change in the code to accomplish this.

Below I have a piece of the case statement. I know that on the code below the "product_info.php" page is the one the case will apply to. I want to change this so it only applies to the [b]index.php?cPath=10[/b], but I don't know how to do this.

Can somebody tell mw what I have to change below so the case statement will apply to "cPath=10"?

[code]
case ( (strstr($_SERVER['PHP_SELF'],'product_info') or strstr($PHP_SELF,'product_info')) ):
[/code]


Thank you,

olimits7

Share this post


Link to post
Share on other sites
Hello,

its kinda hard to change only one part of the code and expect it to do all you want without seeing the whole thing. is like you bringing a motor to my shop and telling me to change the spark plugs for something else to make your car go faster without ever seeing the car!

but if I would have to give it a try i would change from this:

case ( (strstr($_SERVER['PHP_SELF'],'product_info') or strstr($PHP_SELF,'product_info')) ):

to this:


case ( (strstr($_SERVER['PHP_SELF'],'index.php?cPath=10') or strstr($PHP_SELF,'index.php?cPath=10')) ):

Now! This mostliley wont work because if I guess correctly whatever function the case statement comes from it takes the variable from between the quotes and adds the '.php' to it in order to work. So if that is true the code I gave you above would transform your path into:

index.php?cPath=10.php which I am guessing that is not what you want. :)

Now if you show us more of your code we might be able to change the whole deal to behave the way you want it.

Share this post


Link to post
Share on other sites
Hello, fusionpixel.

Thank you for your help, I really appreciate it.

This is the whole code from my *.php file. The file is for my osCommerce website, and I would like to show the banner only on the "index.php?cPath=10" page. You can see the case statement below, where it says "// add new case statement for additional pages".

If you have another way of doing this besides using the "strstr", I'm all ears. I don't care what code I use I just want to get it to work.

I tried posting this on the osCommerce forum, but no seems to respond to anything I write. I feel like I'm talking to myself at the osCommerce forum. haha.

[code]
<?php
/*
// WebMakers.com Added - Banner Manager - Column Banner
// Created by: Linda McGrath osCOMMERCE@WebMakers.com
// Test at: http://www.thewebmakerscorner.com
*/
?>
<?php
// BOF: WebMakers.com Added: Banner Manager - Column Banner
  $my_page_ssl=$HTTPS;

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_BANNER_MANAGER);


// define banner group per page
// add new case statement for additional pages
  switch (true) {
  case ( (strstr($_SERVER['PHP_SELF'],'default') or strstr($PHP_SELF,'default')) ):
    $use_banner_group = '125x125';
    break;
  case ( (strstr($_SERVER['PHP_SELF'],'product_info') or strstr($PHP_SELF,'product_info')) ):
    $use_banner_group = 'product_info 125x125';
    break;
  default:
    $use_banner_group = '125x125';
    break;
  }

  if ($banner = tep_banner_exists('dynamic', $use_banner_group)) {

    switch (true) {
    case ( BANNERS_SHOW_ON_SSL=='1' and $my_page_ssl=='on' ):
      $show_banner_ad='1';
      break;
    case ( BANNERS_SHOW_ON_SSL=='0' and $my_page_ssl=='on' ):
      $show_banner_ad='0';
      break;
    default:
      $show_banner_ad='1';
      break;
    }

    if ( $show_banner_ad=='1' ) {
?>
<!-- column_banner //-->
          <tr>
            <td>
<?php
  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'center',
                               'text'  => BOX_HEADING_COLUMN_BANNER
                              );
  new infoBoxHeading($info_box_contents, false, false);

  $info_box_contents = array();
  $info_box_contents[] = array('align' => 'center',
                               'text'  => tep_display_banner('static', $banner)
                              );
  new infoBox($info_box_contents);
?>
            </td>
          </tr>
<!-- column_banner_eof //-->
<?php
    }
  }
// EOF: WebMakers.com Added: Banner Manager - Column Banner
?>
[/code]

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Now! This mostliley wont work because if I guess correctly whatever function the case statement comes from it takes the variable from between the quotes and adds the '.php' to it in order to work. So if that is true the code I gave you above would transform your path into:

index.php?cPath=10.php which I am guessing that is not what you want. :)
[/quote]

You're correct about this it does add the *.php to the end of the file. Do you where I have to look to see where the function comes from that makes it add the *.php to the end of it?

I'm really new with PHP, but I appreciate your help with these simple questions.

Thank you, again.

olimits7

Share this post


Link to post
Share on other sites
Uh...

[code]if($_GET["cPath"] == "10"){
     case ( (strstr($_SERVER['PHP_SELF'],'product_info') or strstr($PHP_SELF,'product_info')) ):
}[/code]

Am I missing something?

Share this post


Link to post
Share on other sites
Hello,

I just tried what you wrote above, but it didn't work.

The "if" statement seems right, but then it's just showing the banner on the "product_info.php" file when cPath is equal to 10. So it is showing the banner on the wrong file.

I need the banner to show only on the "index.php?cPath=10" when I navigate to that page. So I have to somehow figure a way to change where it says "product_info" in the code so it points to "index.php?cPath=10".


Thank you,

olimits7

Share this post


Link to post
Share on other sites

×

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.