((basename($ PHP_SELF)== FILENAME_DEFAULT

时间:2012-08-26 08:52:45

标签: php

我希望右框只能看到index.php
代码

if ($oscTemplate->hasBlocks('boxes_column_right')) {
?>
<div id="columnRight" class="grid_<?php echo $oscTemplate->getGridColumnWidth(); ?>">
<div><?php echo $oscTemplate->getBlocks('boxes_column_right'); ?></div> 
alternative with index page
if ($oscTemplate->hasBlocks('boxes_column_right')) && ((basename($PHP_SELF) == FILENAME_DEFAULT)) {
?>
<div id="columnRight" class="grid_<?php echo $oscTemplate->getGridColumnWidth(); ?>">
<div><?php echo $oscTemplate->getBlocks('boxes_column_right'); ?></div> 

但它没有

2 个答案:

答案 0 :(得分:0)

你可以这样做:

$basename = str_replace(".php","",basename($_SERVER['REQUEST_URI']));
if( $basename == "index" ) {
  //show right column
} 

OR

$name = basename($_SERVER['PHP_SELF']);
if ($oscTemplate->hasBlocks('boxes_column_right')) && (($name == "index.php")) {
  //show right column
}

你的意思是那样吗

答案 1 :(得分:0)

我用它做了类似的任务:

if ($current_page = FILENAME_DEFAULT) { //Show }