1

When the 'posts/index' action is executed the 'views/posts/index.ctp' is called.

In 'views/posts/index.ctp' there is presentation of results.

I don't want to create/have/get that 'views/posts/index.ctp' file.

I want to present the result from the 'posts/index' action, I don't need 'views/posts/index.ctp' file.

How can I do this ?

3 Answers 3

4

You need to set the autorender to false:

$this->autoRender = false; //any echo's will be printed as the "view" echo "My Posts\n"; 

Optionally, you can even omit the layout by using:

$this->layout = false; 
Sign up to request clarification or add additional context in comments.

Comments

1

If you do not want a method to automatically load a view, you can set $this->autoRender = false inside that method.

You can also use the render() method to render a view whose path does not follow CakePHP conventions.

Comments

1

If you don't want to create views you shouldn't be using a Model-View-Controller framework.

2 Comments

So is it geting like Model-Controller framework ? Note: this is only for one action, not for all actions.
I see. For some reason I got the idea you just didn't want to have anything to do with creating views. Out of curiosity, what makes this one action different from the others?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.