How to render a static html

Hi there,

I've a doubt. How can i render a static html file from an action? I don't want an engine template like volt or phtml in this unique case.

Thanks, Raul.

Hey, what do you want to do? Render the HTML into a variable or just use static HTML (without PHP) as template for currenge page?



296

Hey Nikolay,

Just use static html(whitout php) as template, exactly.

I want use angular2 in this page.

Thanks,

Hey, what do you want to do? Render the HTML into a variable or just use static HTML (without PHP) as template for currenge page?

edited Jul '16

I see. Unfortunately I'm not a big fan of angular when it comes to websites, but perhaps this thread can help you: https://forum.phalconphp.com/discussion/2909/using-a-angular-js-framework-with-phalcon ?

Other members will give ideas too I bet ! :)



61.1k

i think in phalcon 2.1.x you can

$this->view->disableLevel(View::LEVEL_MAIN_LAYOUT);

return "<html><body> my angular body</body></html>";

but i dont think that makes any sence. Whats the problem of just changing the layout for this action and using standart view ( whatever your app is using ), and include the js there.

https://docs.phalconphp.com/en/latest/reference/views.html#disabling-render-levels

// i havent used angular

edited Jul '16

I think the methodology here is wrong..

why are you rendering your index page wtih phalcon at all?

Angular sites use ajax requests to build themselves.

So your front end and your back end are decoupled completely. you can server your front end completely statically on your server then put your phalcon app in teh back end return the JSON you need for your Angular app.

myappishere.com your static webserver for your front end.

api.myappishere.com your phalcon backend to talk to the database.

Keeping those services separte will help in the future if you want to add other services from other locaitons in the future. Angular is their to pull data from X places and determine what to render to the screen. adding in new services becomes as simple as adding a new phalcon app somewhere...

say you want to add a chat service, you can add it with something like 0MQ, by calling chat.myapp.com, without having to rely on an phalconness, then you can have your 0MQ service post chats to your phalcon app in the back ground for storage/recall. There are just to many advantages to not rellying on phalcon if you are going angular IMO.