Hi, I have a question that on the surface is probably pretty simple, but with a couple of caveats...

What I have is a membership site, where the members have a replicated website, and their personal link is the domain.com/username

I use htaccess MOD ReWrite to capture the members username from the end of the URL and assign it to a session variable to track through all pages of the website... All of that works fine, and has for a long time..

php_value session.gc_maxlifetime 14400
RewriteEngine On
RewriteRule ^([a-z0-9]+)$ /index.php?m=$1 [NC,L] # captures member username no case last rule

Second special issue is that I use a template system that I created so all pages look the same with the headers and a right and left gutter that display specific links on all pages...

Now, my issue is that I have something the the site owner wants added in the right gutter that while it is nifty stuff... slows the system down, so I want to only disply it when the /index.php page is displayed, as opposed to on all pages as it is now.

I need to determine when someone is on the index page to display it, but not sure how to make that determination with the username after the / in the url...

Maybe it is simple and I'm overthinking it ( have been known to do that )...

Any feedback would be greatly appreciated.

Thanks
Douglas

Recommended Answers

All 2 Replies

Member Avatar for diafol

It all depends on how you're implementing your templates.
I suppose a catch all would be to check the basename of the page:

$showNewWidget = false;
if(basename($_SERVER['PHP_SELF']) =='index.php')$showNewWidget = true;

Again, where you place this is difficult to say as I'm not sure how you're applying templates. If you have a common include file that's placed before any template included, that may work for you.

So in the template holding the widget you could then do:

if($showNewWidget){
    //place your widget code here
}

or even use it to decide whether to include the widget if it is held in a dedicated file:

if($showNewWidget){
    include('coolstuff/widget.php');
}

Or a simplified version of your suggestion...

And it works PERFECTLY....

Thank you for such a succinct response...

Douglas

<?php
    if(basename($_SERVER['PHP_SELF']) =='index.php'){
    // wrap the globe in conditional phrase only if on index page
?>
<center><script type="text/javascript" src="http://jb.revolvermaps.com/t.js"></script></script>
<?php
 }
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.