Skip to content

Commit

Permalink
Add doc for customizing hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
goosys committed Sep 25, 2024
1 parent fe50364 commit cc8d779
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/customizing_page_views.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,28 @@ rails generate administrate:views:layout
# It only generates the sidebar partial
# -> app/views/admin/application/_navigation.html.erb
```

## Customizing for a specific layout

You can use several hook points to add elements to specific layouts or specific pages.

- header_middle
- header_last
- before_main
- main
- after_main

For example, you can add a button in the middle of the header as follows.

```eruby
<%# app/views/admin/customers/_index_header.html.erb %>
<% content_for(:header_middle) do %>
<div>
You are logged in as <em><%= pundit_user.name %></em>.
<%= link_to("Become the Admin", become_admin_customer_path("admin")) unless pundit_user.admin? %>
</div>
<% end %>
<%= render template: 'administrate/application/_index_header', locals: local_assigns %>
```

0 comments on commit cc8d779

Please sign in to comment.