How can i override LiveView Layout("live.html") with use AppnameWeb, :live_view

I want to use other layout “hoge.html.heex” on live view.

The following code works as expected!

# view
use Phoenix.LiveView, layout: {HogeAppWeb.Other.LayoutView, "live.html"}

But the following code doesn’t work as expected.

# view
use HogeAppWeb, :live_view

# router.ex
  pipeline :hoge do
    plug(:put_layout, {HogeAppWeb.Other.LayoutView, "live.html"})

   scope "/", HogeAppWeb do

     live("/articles", ArticleLive.Index, :index)

Is there any way?

use HogeAppWeb, :live_view refers to the live_view/0 function in your lib/hoge_app_web.ex. You need to go into that file and make the changes there.

thanks for your reply!

I changed live_view/0 generated by phoenix, it expected works :+1:

1 Like