0

if i used this it's working. but if i rename function name, it shows error

IN view file:

echo $this->Html->link( '<span>Page 1</span>', array('action' => 'ra'), array('escape' => false));

In controller:

public function ra() { $this->render('ra'); } 
1
  • 2
    Please show a little effort when asking questions. Make your code readable, explain exactly what the problem is, what you have tried to solve it, and also mention your exact CakePHP version. Commented Sep 25, 2013 at 9:10

2 Answers 2

1

By convention, the view file must be the same as the method (action) name.

If you want to change the appearance of a URL, you should use routes, rather than rename your methods/views.

If you wish to render a different .ctp file for a given action, then you can override the default behaviour like so:

public function ra() { $this->render('my_other_view'); } 

The action specified in the URL must always exist to avoid an error (but routing lets you use alternative "names" for the action and maps them to the appropriate controller method).

Sign up to request clarification or add additional context in comments.

Comments

0

View template files are named after the controller functions they display, in an underscored form. The getReady() function of the PeopleController class will look for a view template in /app/views/people/get_ready.ctp.

The basic pattern is /app/views/controller/underscored_function_name.ctp.

By naming the pieces of your application using CakePHP conventions, you gain functionality without the hassle and maintenance tethers of configuration. Here’s a final example that ties the conventions

Database table: “people” Model class: “Person”, found at /app/models/person.php Controller class: “PeopleController”, found at

/app/controllers/people_controller.php View template, found at /app/views/people/index.ctp 

Read : View Conventions

Also Read : CakePHP Conventions

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.