Sidi_Mohammed
LiveView custom layout not rendered
Hello,
I have a custom layout for use in a pipeline as
pipeline :admin_required do
plug MyAppWeb.Plugs.AuthAdmin
plug :put_root_layout, ...
plug :put_layout,...
and plug it as
scope "/admin" do pipe_through [:admin_required]
get "/"...
get "/data"...
live "/dashboard"...
end
For the two get routes everything works fine, but for the live route the custom layout is not rendered, why please ?
Marked As Solved
karim-semmoud
If I understand correctly you have one root and 2 layout lets call them app(the original) and admin
To decide with Live View will be using which layout you need to edit your MyappWeb.ex
The original is as follow, keep it as it is
def live_view do
quote do
use Phoenix.LiveView,
layout: {MyappWeb.Layouts, :app}
unquote(html_helpers())
end
end
Create a new one under
def live_view_admin do
quote do
use Phoenix.LiveView,
layout: {MyappWeb.Layouts, :admin}
unquote(html_helpers())
end
end
and then in your Admin Live View you do
use MyappWeb, :live_view_admin
Also Liked
mindok
Hi @Sidi_Mohammed - a bit more information is needed to provide you with any help. e.g. is an error displayed? Is there an error in the logs? What is your actual live "/dashboard"... definition? (i.e. what is “…”). What does the liveview code look like relating to the definition.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








