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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:15:55+00:00 2026-05-29T06:15:55+00:00

I have some controller logic: public function seafood() { $this->set(‘title’, ‘Seafood restaurants in and

  • 0

I have some controller logic:

public function seafood() {
$this->set('title', 'Seafood restaurants in and near Gulf Shores, AL');

$this->paginate['Restaurant']=array(
        'limit'=>9,
        'order' => 'RAND()',

        'conditions'=>array(

                'Restaurant.active'=>1,
                'Restaurant.seafood'=>'Seafood'
                )   
    );
$data = $this->paginate('Restaurant');
$this->set('seafood', $data);




}

This gets repeated like 13 times, with 13 different view pages labeled “seafood, waterfront, steakhouse” etc. The view is exactly the same, everthing is the same really, except the controller has to find by a specific type of restaurant. Can someone please explain to me how I can just make one view file that would show up at say http://www.site.com/restaurants/seafood?

Truth be told, all of my results pages are some variation on this. I tell cake to paginate (and usually contain) some model’s data, then stick it into a view that is almost identical (with an icon or two difference) to all the other pages. I am building a site that is one of those “things to do and see in x beach town”, so I have restaurants, places to stay, shopping, nightclubs, golf courses, etc (it is all over the place).

My boss has given me this gargantuan website to build and I really don’t know any programming logic very well. I’d like to stick to the DRY concept here so that I can really learn this stuff.

UPDATE

Ok, I made sure my routes had this in the file:

Router::connect('/restaurants/:action', array('controller'=>'restaurants'));

I kept my seafood.ctp file, then took out my seafood() function and stuck this in instead:

 public function restaurants($restaurantType) {

$this->set('title', $restaurantType.' restaurants in and near Gulf Shores, AL');

$this->paginate['Restaurant']=array(
        'limit'=>9,
        'order' => 'RAND()',

        'conditions'=>array(

                'Restaurant.active'=>1,
                'Restaurant.seafood'=>$restaurantType
                )   
    );
$data = $this->paginate('Restaurant');
$this->set($restaurantType, $data);
}   

When I accessed the page at http://www.site.com/restaurants/seafood cake told me that my controller was missing the method seafood(). What did I miss?

  • 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-05-29T06:15:56+00:00Added an answer on May 29, 2026 at 6:15 am

    Try this:

    Router::connect('/restaurants/:restaurantType', array('controller'=>'restaurants', 'action' => 'restaurants'));
    

    The reason it’s not finding it, is because you’re still using the standard :action parameter. You just need to change it so the action remains the same, that way it gets passed into the action as parameter.

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

Sidebar

Related Questions

I am getting some unexpected behavior from Html.EditorFor(). I have this controller: [HandleError] public
I have this in my controller. I need my view to generate some HTML,
I have a controller merchant_import and creating an array from xml public function merchant_import_kgb(){
I have a controller user with a method login For some reason, when I
I have a namespaced controller for some admin functionality. My create form does not
I have a controller with that I want to pass off some data to
I have a view controller that gets presented modally and changes some data that
I have a spring action that I am rendering some json from the controller,
Lets say I have a view, myView, a view controller, myViewController, and some sort
I have a number of functions in my controller logic and for every one

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.