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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:41:27+00:00 2026-06-10T13:41:27+00:00

I have a site developed in cakephp 2 and I want that into my

  • 0

I have a site developed in cakephp 2 and I want that into my default.ctp there is a menu with some elements taked from the database.
How can I change the elements which controller I have to use? Where I have to put my query? Because if I was into a model is easy but into the default.ctp? How can I do that?
Here is my default.ctp:

<body>
        <div class="content">
            <div id="navigation">
                <ul>


                    <?php
                        if (!empty($authUser)) {
                        ?>
                        <li><?php echo $this->Html->link('I want to change this',   array('controller' => 'ingredients',    'action' => 'index')); ?></li>
                        <li><?php echo $this->Html->link('I want to change this',       array('controller' => 'brands',         'action' => 'index')); ?></li>
                        <li><?php echo $this->Html->link('I want to change this',   array('controller' => 'manufacturers',  'action' => 'index')); ?></li>
                    <?php
                            // $is_logged from UsersController->beforeFilter
                            echo $this->element ('header_menu_logged');
                        } else {
                            ?>
                            <li><?php echo $this->Html->link('Competizioni',        array('controller' => 'brands',         'action' => 'index')); ?></li>
                            <li><?php echo $this->Html->link('Cerca',   array('controller' => 'manufacturers',  'action' => 'index')); ?></li>
                            <?php
                            // $current_model
                            echo $this->element ('header_menu', array('selected' => 'Pippo'));
                        }
                    ?>
                </ul>
            </div>
            <div class="page">
                <?php
                // messaggi di stato per le azioni

                if (empty($flash_element)) {
                    $flash_element = $this->Session->read('flash_element');
                    if (empty($flash_element)) {
                        $flash_element = 'default';
                    }
                }

                // echo '>'.$flash_element.'<';

                $auth_msg = $this->Session->flash('auth', array ('element' => 'flash_'.$flash_element));
                $flash_msg = $this->Session->flash('flash', array ('element' => 'flash_'.$flash_element));

                if (!empty($auth_msg)) {
                    echo $auth_msg;
                }

                if (!empty($flash_msg)) {
                    echo $flash_msg;
                }
                ?>

                <section><!--class="contents"-->
                <?php echo $content_for_layout; ?>
                </section>
            </div>
        </div>
    </body>
  • 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-10T13:41:29+00:00Added an answer on June 10, 2026 at 1:41 pm

    Well, I suggest doing $this->set('anyString', $varStringOfTheLink); in your beforeRender() or beforeFilter() in appController.php .

    Do your query from there and then use the set() function to set a variable for your view.

    Then in default.ctp you will be able to use $anyString.

    So to do a quick wrap-up. Do the query in your appController, before filter or before render, then set it so your view can use it. The first parameter of the set() function is the name of the var you want to use in your view. Just put a $ before. The second paremeter is the value of the variable you want.

    //appController.php
    function beforeFilter(){
        $myQueryVar = $this->Model->find('whateverIWant');
        $this->set('myLinkOne', $myQueryVar);
    }
    
    //layouts/default.ctp
    echo $this->Html->link($myLinkOne,   array('controller' => 'ingredients',    'action' => 'index'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a web site that requires user registration and authentication for some
I have a site developed in cakephp 2.0, I have some tables relationed here
I have a site developed with django at www.example.com I want that django insert/serve
I have a site developed in cakephp 2.0, I want to make a relation
I have a site develop in cakephp 2.x I want into my controller call
I have a site developed in cakephp 2.0 and I want to see, when
I have developed a site that allows the users to embed widgets into their
I have developed a site, which has some static pages. Like explore, home, feedback.
I have a asp.net web site that was developed on the .Net Framework v2
Hey guys, I have developed a small site that i would like to embed

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.