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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:59:46+00:00 2026-06-02T05:59:46+00:00

I have a main view with a menu which helps me display another view.

  • 0

I have a main view with a menu which helps me display another view. It’s similar to this:

<div id="page">
    <div id="menu">
            <a href="controller/page1">Page1</a>
            <a href="controller/page2">Page2</a>
    </div>
    <div id="content">
            <!-- Page1 or Page2 are displayed here -->
    </div>
</div>

I’m using php’s Yii framework. Which makes me not to use <?php include("menuview.php"); ?>. So I’m looking for a different solution. I can do this with Ajax, but I would also like the link to change to mypage/controller/Page2. With Ajax I can only get it to this: mypage/controller/index#Page2

  • 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-02T05:59:48+00:00Added an answer on June 2, 2026 at 5:59 am

    in main view, instead of include do

    <?php echo $this->renderPartial('_page1', array('model'=>$model)); ?>
    

    UPDATE:

    protected/views/controller/page1.php and protected/views/controller/page2.php content at your liking

    protected/views/layouts/custom.php:

    <?php $this->beginContent('//layouts/main'); ?>
    <div id="page">
        <div id="menu">
            <?php echo CHtml::ajaxLink('Page1', array('controller/page1'), array('update' => '#content')); ?>
            <?php echo CHtml::ajaxLink('Page2', array('controller/page2'), array('update' => '#content')); ?>
        </div>
        <div id="content">
            <?php echo $content; ?>
        </div>
    </div>
    <?php $this->endContent(); ?>
    

    protected/controllers/ControllerController.php:

    class ControllerController extends Controller {
    
        /**
         * @var string the default layout for the views.
         */
        public $layout = '//layouts/custom';
    
        public function actionPage1() {
            if (Yii::app()->request->isAjaxRequest)
                $this->renderPartial('page1');
            else
                $this->render('page1');
        }
    
        public function actionPage2() {
            if (Yii::app()->request->isAjaxRequest)
                $this->renderPartial('page2');
            else
                $this->render('page2');
        }
    
    }
    

    UPDATE2:

    If you need the link in address bar to change too then your only option is to use regular link and not ajax <?php echo CHtml::link('Page1', array('controller/page1')); ?>

    using ajax the preferred way is using hash like you mentioned.

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

Sidebar

Related Questions

I'm developing an iOS 4 application. I have a main view that contains another
In the main view i have this function public function lang($file, $language){ require 'languages/'.$language.'/'.
I have an application composed of a main view and a secondary view which
I have below html code in one of the opensource project. <form action=/wiki/bin/view/Main/Search> <div
I have a view which was working fine when I was joining my main
I have a Cocoa app with a ManMenu.xib, in which the main menu is
My main view controller (representing the Main Menu in my app) has a simple
I have ordinary activity with Option Menu, which I created by this code: @Override
I'm using the navigation controller project. I'd like to have a main menu without
I have a table view which loads another xib file and uses the content

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.