I would like these buttons: to allow my users to edit the listing they're currently viewing, instead of the page they're viewing. How would I do that?
Example:
Clicking on the pencil above takes them to the edit page screen, but the page is just a holder for the app. How can I make it edit the current listing instead?
Comments
I've been thinking about a way to make these easier to reuse. For now, take a look at
apps/admin/views/editable.html
for how they're setup for pages. You can see how it's called inapps/admin/handlers/page.php
. Basically, you would duplicate and tweak the view template, then:It works, but now there are two rows of buttons.
It would be great if there were a way to disable the page buttons.
I think you may need to do that via Javascript:
Hiding the main buttons does mean editing that page itself is only possible through the Tools > All Pages screen, so you could try something like repositioning it instead or styling them differently in some way (that may look weird though).
In this case it's OK because I don't really want the client editing the page, which just looks like this:
The script works, thanks.
Is this still the way to do this? I notice that there are new
data-trigger="[aevd]"
attributes inapps/admin/views/editable.html
-- what do those do?Also, how about adding add/edit/lock/version buttons to each item in a list of items, for example each event on an event listings page -- possible?
That was still the way I was doing it, but I just added a new admin/util/editbuttons helper to make things easier. Here's a usage example:
1. Create the app:
2. Modify the
books/index
handler to fetch the books:3. Modify the
books/index
template to add the edit buttons:That will insert the edit buttons tied to your new app, hiding them for non-admin users, and respecting edit locks as well.
The
data-trigger
attributes are for keyboard shortcuts. To pull up a list of available shortcuts on the current page, useCtrl+Shift+h
.That looks great!
One thing I'd like to add is the ability to inject additional buttons, maybe via an
&extras=[extras]
parameter where the[extras]
would look something like this:That'd be cool. Might need to allow for choice of icon, too. Also, what about the ability not to include certain buttons -- if versions weren't being tracked, say? Or can we already do that just by not including
versions=true
?Yep, you can omit any of the existing buttons just by leaving them out.