atom
atom copied to clipboard
Unable to change Authority Record slug
Currently it is not possible to change the slug of an authority record once it has been created. Advice from Dan in the forum is to use SQL against the database directly to do this. Regenerating slugs
In order to avoid this I modified the QubitActor.php file as per the following diff:
index f36bfebc2..4869dcadb 100644
--- a/lib/model/QubitActor.php
+++ b/lib/model/QubitActor.php
@@ -140,6 +140,17 @@ class QubitActor extends BaseActor
{
$this->parentId = QubitRepository::ROOT_ID;
}
+
+ // Added by rferris to allow changing authority record slugs
+ $newQubitSlug = QubitSlug::getByObjectId($this->id);
+ if (isset($newQubitSlug)) {
+ $slug = QubitSlug::slugify($this->__get('authorizedFormOfName', array('sourceCulture' => true)));
+ if ($slug !== $this->slug) {
+ $this->slug = $slug;
+ $newQubitSlug->slug = $slug;
+ $newQubitSlug->save();
+ }
+ }
This allows a user to simply edit the record, change the title, hit save, and have the slug change accordingly. As far as I can tell this is effectively no different to doing this via SQL and the CLI slug utility. Whether it's the way the team at Artefactual would go about this or not, I'm not sure. I did, however, want to provide my change for your consideration.
Hi @rferris !
Thanks so much for sharing this idea. While we would love to see a method for end users to easily update authority record slugs to AtoM's user interface, at this time, I'm not sure this is a solution we will implement. Changing the permalink of a resource in AtoM without the user explicitly choosing to do so could have unexpected consequences - for example, breaking every external link added to third-party websites.
Long term, our preferred solution would be to add support for a Rename module for authority records, similar to what we've added for descriptions, as described in our docs here:
- https://www.accesstomemory.org/docs/latest/user-manual/add-edit-content/archival-descriptions/#rename-the-title-or-slug-of-an-archival-description
If you are curious to see the code behind this, here are some of the main files used:
- https://github.com/artefactual/atom/blob/HEAD/apps/qubit/modules/informationobject/templates/renameSuccess.php
- https://github.com/artefactual/atom/blob/HEAD/apps/qubit/modules/informationobject/actions/renameAction.class.php
- https://github.com/artefactual/atom/blob/HEAD/js/rename.js
I'll leave this issue open for now, to make it easier for others to find your code snippet in case they would like to implement this locally.
Cheers,
Dan Gillean, MAS, MLIS AtoM Program Manager
Hi Dan,
Agreed - my quick fix here definitely isn't ideal. I'll see if I can get time to create a rename form and if I can I'll do a pull request on it. :)
Cheers, Rohan
Fix merged in: https://github.com/artefactual/atom/pull/1542