Is the proper/simplest way to change the Layout of a Template to use the put_layout
method within each Controller action? A simple example of wanting a different La
I think you might be best off by setting a default layout.
defmodule MyPhoenix.AController do
use MyPhoenix.Web, :controller
plug :put_layout, "LayoutA.html"
def pageOne(conn, _params) do
render conn, "page1.html"
end
def pageTwo(conn, _params) do
render conn, "page2.html"
end
end
defmodule MyPhoenix.BController do
use MyPhoenix.Web, :controller
plug :put_layout, "LayoutB.html"
def pageOne(conn, _params) do
render conn, "page1.html"
end
def pageTwo(conn, _params) do
render conn, "page2.html"
end
end
If for example you need a different layout for say all admin controllers which are covered by separate admin pipeline in the router you can specify plug :put_layout, {MyApp.LayoutView, :admin}
for the admin pipeline. I learned it from http://www.cultivatehq.com/posts/how-to-set-different-layouts-in-phoenix/.