Jump to content

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
Link to comment
https://forums.phpfreaks.com/topic/4804-beginner-help-with-small-change-in-code/
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.
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
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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.