Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8006189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:25:42+00:00 2026-06-04T17:25:42+00:00

I have a situation here. In my project the menu section contains some anchor

  • 0

I have a situation here. In my project the menu section contains some anchor tags, it will work perfectly when we in index page, but moving to other pages i want to give the real links there, so my question is how to check which page is viewing or how to check the the site viewer is not in index page

<li><a href="#home" class="active">Home</a></li>
<li><a href="#about_us">About Us</a></li>

I want to change href conditionally, for example when I’m in index the above href attribute is OK, and when I’m in another page, for example register, then the href attribute change to index.php/site/index#home

Thanks in advance

UPDATE :
thank you uttara,I found a solution with the help of her

<?php
$url = $_SERVER["REQUEST_URI"];
$page = pathinfo($url);
$filename = $page['filename'];
$href = ($filename=='root_directory' || $filename=='index'  || $filename=='site')?'':Yii::app()->request->baseUrl;
?>
<a href="<?php echo $href ; ?>#home" class="active">Home</a>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:25:43+00:00Added an answer on June 4, 2026 at 5:25 pm
    $url = $_SERVER["REQUEST_URI"];
    $page = pathinfo($url);
    $filename = $page['filename'];
    

    $filename will give you the name of current page being viewed

    and you can check for

    if($filename != 'index')
    {
        echo '<li><a href="index.php/site/index#home" class="active">Home</a></li>
              <li><a href="#about_us">About Us</a></li>';
    }
    else
    {
        echo '<li><a href="#home" class="active">Home</a></li>
                  <li><a href="#about_us">About Us</a></li>';
    }
    

    remember $filename gives you just the filename without extension

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my situation: I have a C project linking with many libraries (I
Here is my situation: I have one table that contains a list of drugs
Here's my situation. I have a web forms page, and it's getting annoying when
I have a project that contains several submodules, that communicate using some objects that
Here is the situation. I have a django project with two installed apps. Both
so, here is the situation here. I have 2 asp.net websites + some winform
I have a strange situation here. In my android app, I have a layout
I have a simple situation here. lets face html code first => <form name=geoKey
I have a unique situation over here. I have a button on a form
I have a really tough situation in here. There is an array of these

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.