Little tips for a plugin

Hello,
I’ve started developing a new plugin to add data to items.
I need to implement a way, for every row in the item page, to add some data to it.
I read all the documentation but it’s a bit weird and i didn’t find it clear.
What should i do is to add a fourth button on for each row.

  1. I imagine to do it by copying the "view/omeka/admin/item/manage-media.phtml " into “my_module_name/view/omeka/admin/item/manage-media.phtml”. is this the best practice?

  2. By clicking the button a modal will appear (I think i can do it into the same view, right?). I need to store the data that the user will input in the JSON-LD of the item. How can i do this? from where?

Thank you so much in advice! I don’t need any codes, just some tips on where and how to move :smiley:

What are you trying to do more generally? You’ve mentioned both items and media.

It’s possible to override whole views like you say here, though typically modules use events and things like that to make smaller changes instead.

I try to be more clear, Foreach property of a generic item that is going to be inserted i need to add a button to that row. That button will show a modal to insert new data to give an additional description for that property.
image
Any idea how can I read all the property that an item has (or will have) and how to add and store new data for each property?
Is overriding the view like i specified in the first comment the right way to edit the view for my purpose?
Once i have all properties of an item, my idea is to store, for every property “dcterms:property” the additional data in an object “dcterms:property_modulename”

@jflatnes Any idea how can I achieve my goals? I need to import a css library too for customize my buttons/dialog

It’s possible to do what you’re talking about by totally overriding the view, at least the UI part of it. That’s going to be annoying to keep up with, as any changes we make to the “normal” controller/view/js/etc. could affect your module. So I probably wouldn’t recommend it.

That interface is pretty much run on JS, so it might be better to go that route to alter the UI rather than changing the actual markup. This is one of the more complex and fundamental pieces of the UI and data model for S, so it’s relatively complex to add things here outside the handful of “blessed” areas for extension we provide (like data types).

Another user has done something somewhat similar that you might look to for inspiration: New Relators Module (Looking for input) : they are adding extra data alongside regular values.

If your extra info is really associated with the properties and not the values then you could go a totally different route and not add your functionality to this view at all, but that would only work if the “extra data” is the same for a property no matter which item it is used in… I think from your description that’s not exactly what you want.

The idea behind this is to be able to say “this painting is maybe from X maybe from Y maybe from Z. I’m not sure at the moment” and other informations like this.
I will probably override the view (because i need to finish this plugin as soon as i can, and probably, after installed, the system where the plugin will run will not be updated so much) responsible to draw the buttons to add the new button and display the modal (I already did it). Now my problem is:

  1. “how can I get the name of the property the buttons are linked?”.
    If i click on the button in the dcterms:title, how can i say i clicked on the button about dcterms:title and not dcterms:description?

  2. After i will be able to say “I clicked the button relative to dcterms:property”. how can I add the values the user inserted in the JSON representation of the item?

Thank you so much in advice! I’m really struggling with this part!

@jflatnes Any suggestion how I can do what I described before? :smiley:

Did you look at that other module at all? What it’s doing is in many ways similar to what I think you’re trying to do.

The data about what property the button relates to is available on data embedded in the markup: the “data-property-term” attribute of the “field” container holds the term for each property: you can get at it by pulling that attribute or by using the dataset API or jQuery’s .data.

Adding the values to the JSON itself, there’s an event used to modify the JSON: rep.resource.json. You’ll have to handle where to actually save that data so you can get at it later though… adding your own table is one option for doing this.

Tried to look ad others module but didn’t find any input to advance.
If i use something like $(".resource-values.field").data(); I always got “dcsm:title” even if I have clicked on a button of different term.
Anyway, i still don’t understand why i need to add a new table… can’t I save it directly in the JSON representation of the document?