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 8832719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:35:54+00:00 2026-06-14T08:35:54+00:00

Drupal has a function called drupal_is_front_page . Does YII have something similar to deal

  • 0

Drupal has a function called “drupal_is_front_page“. Does YII have something similar to deal with navigation in this way?

  • 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-14T08:35:56+00:00Added an answer on June 14, 2026 at 8:35 am

    Unfortunately not. And while the information needed to piece this together is available, doing so is really more pain than it should be.

    To begin with, the front page is defined by the CWebApplication::defaultController property, which can be configured as discussed in the definitive guide. But there’s a big issue here: defaultController can in reality be any of the following:

    1. a bare controller name, e.g. site
    2. a module/controller pair, e.g. module/site
    3. a controller/action pair, e.g. site/index
    4. a module/controller/action tuple, e.g. module/site/index

    If you have specified the defaultController as #4 (which is the same as #3 if your application does not include any modules) then everything is easy:

    function is_home_page() {
        $app = Yii::app();
        return $app->controller->route == $app->defaultController;
    }
    

    The problem is that if defaultController is specified as #1 or #2 then you have to examine a lot of the runtime information to convert it to form #3 or #4 (as appropriate) so that you can then run the equality check.

    Yii of course already includes code that can do this: the CWebApplication::createController method, which can accept any of the valid formats for defaultController and resolve that to a controller/action pair (where controller is dependent on the module, if applicable). But looking at the source doesn’t make you smile in anticipation.

    To sum it up: you can either assume that defaultController will always be fully specified and get the job done with one line of code, or borrow code from createController to determine exactly what defaultController points to (and then use the one line of code to check for equality).

    I do not recommend looking into solutions based on URLs because the whole point of routes is that different URLs can point to the same content — if you go that way, can never be sure that you have the correct result.

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

Sidebar

Related Questions

It's similar to what Drupal has . My current function definition is like this:
Drupal has a very well-architected, jQuery -based autocomplete.js . Usually, you don't have to
i have form in drupal which uploads images and has got few checkboxes in
Is the hook_block has been changed? the following is drupal 6 example i have
I've been trying to build a site similar in function to craigslist in Drupal.
Drupal 6.x I have this module that manages four different content types. For that
I have function that has to write some data into database table, but after
Okay, I have a page on a Drupal install that has multiple divs. I
Ok, here's the deal: I am constructing a Drupal website that has several different
I have the following jQuery code: $content.each(function(i) { $body = $(this); $(this).find('div.field-content') .animate( {

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.