I’m trying to configure a new layout for the home page (/) so the only way I have found so far is to configure a new pipeline replacing the :root default layout
pipeline :browser_public_layout do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, html: {MyAppWeb.Layouts, :public}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :fetch_current_user
end
...
...
scope "/", MyAppWeb do
pipe_through :browser_public_layout
get "/", PageController, :home
end
is this the right way? it’s confusing for me because Page controller has the following code, having layout = false I thought layout equal to false means no layout at all, but still have the default one → :root
def home(conn, _params) do
# The home page is often custom made,
# so skip the default app layout.
render(conn, :home, layout: false)
end
Also the only way I found was
My first unsuccessful approach was specify the layout in the function but I haven´t found yet the reason why it didn´t work
def home(conn, _params) do
# The home page is often custom made,
# so skip the default app layout.
render(conn, :home, layout: {MyAppWeb.Layouts, :public})
end
Also trying another approach I thought just remove the layout and again the only way I found was create another pipeline with no default layout just like follow:
pipeline :browser_no_layout do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :fetch_current_user
end
...
...
scope "/", MyAppWeb do
pipe_through :browser_no_layout
get "/", PageController, :home
end
So my questions to try to understand it are
- Is the right way to create another pipeline if we just want to use another layout?
- Is the right way to do it, create a new pipeline if we don´t want any layout at all?
- Does the function calling render(conn, :home, layout: false) have a way to pointing out to another layout instead of the default one or at least can be used to remove the default layout
The workaround used for me creating new pipelines was inspired by this question Phoenix Multiple Layouts
Thanks in advance