Open subdigital opened 7 years ago
As you've found, it's not currently possible to change the title in this way without editing the template file (the only way would be to add some custom translations to your i18n .yml
files which wouldn't get you the level of customization you need anyway).
However this is very high on my list of priorities, along with changing the default breadcrumbs. Expect to see something on this within the next week.
Does the content_for()
's found in the templates now a days work for this? or is this still an issue?
For now, setting titles via cloning templates and using content_for
is still the best solution.
However I am right now working on a new API for defining toolbars, which will lead directly into the new actions API. Once that's in place, only extreme customizations will require overriding the templates.
You rock man! Working on plugins I’m thinking... any suggestions?
-- Joshua F. Rountree | UX Developer The E.W. Scripps Company 312 Walnut Street, Suite 2800, Floor 29th, Office 29W109 Cincinnati, Ohio 45202-4024 (513) 977-3840 (office, M-F, 7a-4p) (513) 827-7936 (mobile)
On Aug 16, 2018, 8:26 PM -0400, Sam Pohlenz notifications@github.com, wrote:
For now, setting titles via cloning templates and using content_for is still the best solution. However I am right now working on a new API for defining toolbars, which will lead directly into the new actions API. Once that's in place, only extreme customizations will require overriding the templates. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
I'm not experienced enough with content_for() to figure out how to make use of that method... but did end up realizing it was the show.html.erb that was responsible fro the record titles, not the edit or new.
Any updates in this space? Trying to customize the "human name" for a model which in turn would change the title of a dialog
@jfrux what is human name
? Can you say more detailedly?
i am on 0.8.12
can i change title of the form for the "new route"
i saw the code says
New
I want it to be someothing other than model name for one of the resource/admin
hi:) I know this is a bit stale, but is there still no way to customise not only the titles but also labels for resources?
I know it is "a bit" to late, but I leave this for future references: You can modify your yml file with translations (i.e. en.yml) and add something like this:
en:
admin:
authority_cards:
breadcrumbs:
index: "Authority Cards"
titles:
index: "List of Authority cards"
where authority_cards is the name of the resource. This way you can customise all admin pages
Restarting servers is required/advisable after modification if the translations are not loaded
EDIT: Turns out that this work only for index. To override other actions you need to duplicate the templates show.html.erb and edit.html.erb
So still there isn't a way to make this dynamic other than replacing the whole view, right?
So this is what I was able to do so far:
1) Copy app/views/trestle/resource/index.html.erb
from the gem sources and customize the beginning of the file:
<%
content_for(
:title,
admin.respond_to?(:custom_index_title) ?
admin.custom_index_title :
admin.t("titles.index", default: "Listing %{pluralized_model_name}")
)
%>
2) Define in your admin:
Trestle.resource(:credentials) do
admin.define_method(:custom_index_title) do
title = 'Credentials'
if @context.params[:lock_id]
title += " for #{Lock.find(@context.params[:lock_id]).serial_number}"
end
title
end
end
@spohlenz will you be interested into a PR to do?
Trestle.resource(:name) do
index_title do # self = admin or self = Admin::Controller ?
# ...
end
end
I have a model called
Activity
. How do I get the title to displayEditing #{instance.name}
instead of the generic"Editing Activity"
without writing my own `resource/show.html.erb?I looked for a hook for this and didn't see if this was possible.