First and foremost, thank you for the help thus far social_experiment but I still dont get it because I am a rookie when it comes to writing complex scripts.
Okay I am still very confused Let me go into a little further detail and also show you the piece of the script that I am trying to implement it in.
1) page 1 URL:
http://www.mysite.com/coupons/Internet-Web-Services/ page 2 URL:
http://www.mysite.com/coupons/Internet-Web-Services/ page 3 URL:
http://www.mysite.com/coupons/Computers-Software/ now all of these pages are rewritten using the.htaccess file from a file called tag_result.php
What I tried to do is the following but it did not work. Please explain a little further. I am a total newb when it comes to writing these complex scripts:
<div id="minor">
<!-- google_ad_section_start(name=tags) -->
<div class="panel">
<h3><span>Related Coupon Categories</span></h3>
<div class="inner">
<ul class="tags">
<?php
// Contains the current script's path
$script_name = $_SERVER['SCRIPT_NAME'];
// explode() splits the script name at
// each '/' and places the parts into
// an array
$array = explode('/', $script_name);
// the name of the page is contained in
// the last item of the array. Because
// arrays are indexed from 0, substract
// 1 from the total value to get the
// value of the last index
$amountOfItems = count($array) - 1;
// this name of the page is the only
// part needed for the switch statement
$value = $array[$amountOfItems];
// use a switch statement to determine
// what will display
switch($value) {
case 'PC-Software';
echo 'Test Page';
break;
case 'Food-Groceries';
echo 'something else';
break;
default;
echo 'something entirely different';
break;
}
?>
</ul>
<!-- google_ad_section_end(name=tags) -->
<div class="break"></div>
</div>
</div>
<div class="panel">
<div class="inner">
<div class="break">
</div>
<div class="tagCloud">
<?php
$g_ads = $data->select ( "MarketingAdManager" ,"*", array ( "MarketingPlacing" => "Tag Side Bar" ) ) ;
if ( ! empty ( $g_ads ) )
foreach ( $g_ads as $g_ad )
echo $g_ad["MarketingScript"]."<br><br>" ;
?>
</div>
</div>
</div>
<div class="panel">
<h3><span>Top <?php echo $tag["TagName"] ?> Stores</span></h3>
<div class="inner">
<ol class="topList">
<?php
$websites = $data->select ( "Website_Tag" , "*", array ( "TagID" => intval ( $tag["TagID"] ) ) ) ;
if ( ! empty ( $websites ) )
foreach ( $websites as $website ) :
$web_detail = $data->select ( "Website" , "*" , array ( "WebsiteID" => $website["WebsiteID"] ) ) ;
$web_detail = $web_detail[0] ;
?>
<li>
<a href="<?php echo base_url.get_sef_url ( $website["WebsiteID"] , "Website" ) ?>/" title="<?php echo $web_detail["WebsiteTitle"] ?> Coupon Codes"><?php echo $web_detail["WebsiteName"] ?></a>
</li>
<?php
endforeach ;
?>
</ol>
</div>
</div>
<?php
include ( "inc.social.php" ) ;
?>
</div>
<!-- end: #minor -->
<div class="break">
</div>
</div>
<!-- end: #content -->
</div>
social_experiment wrote:The variable to use is
$_SERVER['SCRIPT_NAME'], it contains the current script's path. Here is an example of code that shows how to use this to get the page value. It takes the current path of the script, explodes it at the forward slashes (/) then selects the pagename value from the array and passes it to a switch statement.
Code: Select all
<?php
// Contains the current script's path
$script_name = $_SERVER['SCRIPT_NAME'];
// explode() splits the script name at
// each '/' and places the parts into
// an array
$array = explode('/', $script_name);
// the name of the page is contained in
// the last item of the array. Because
// arrays are indexed from 0, substract
// 1 from the total value to get the
// value of the last index
$amountOfItems = count($array) - 1;
// this name of the page is the only
// part needed for the switch statement
$value = $array[$amountOfItems];
// use a switch statement to determine
// what will display
switch($value) {
case 'test.php';
echo 'Test Page';
break;
case 'other.php';
echo 'something else';
break;
default;
echo 'something entirely different';
break;
}
?>