AtoM and JQuery

42 views
Skip to first unread message

Stef Emiljanowicz

unread,
Jun 3, 2019, 9:09:27 AM6/3/19
to AtoM Users
Hi,
I'm very, very new to AtoM so apologies if this is a bit of a 'doh!' question... I'm trying to apply some simple visual customisation to the AtoM front end using css and some jQuery. I'm working in _header.php and _footer.php in a plugin template folder. The css works absolutely fine and we've been able to create something a bit more in tune with what we want. I run up against a problem when trying to use JQuery though. 

A simple test shows that JQuery is detected but none of thJQuery code I include (in _footer.php_) appears to work. I can get round this by manually importing jquery into the template from a CDN but then I experience problems with AtoM functionality (specifically the tree structure for navigating to archived materials and the image rotator both fail). 

My first thought was that AtoM uses an old version of jquery (1.8.3) and it didn;t understand the syntax. However if I import 1.8.3 separately from a cdn then my own code works but again I lose functionality.

The issue, or at least part of the issue, therefore appears to be that it doesn't like me (re)importing JQuery but beyond that I'm stuck. 

I have two solutions which both work partially but which appear to cancel each other out.

Any advice would be much appreciated.

Stef

Dan Gillean

unread,
Jun 3, 2019, 12:00:13 PM6/3/19
to ICA-AtoM Users
Hi Stef, 

One of our developers has suggested that you consider writing a custom JS file and add it to the custom plugin templates using the plugin configuration file, like we generally do for custom CSS being included in a theme plugin. 

See for example here, in the arArchivesCanadaPlugin: 
You might also want to use the last argument, to ensure your custom JS is loaded after JQuery. So it would look something like this, added after $context = $event->getSubject();
  • $context->response->addJavaScript('/plugins/theirThemePlugin/js/custom.js', 'last');
Good luck! 


Dan Gillean, MAS, MLIS
AtoM Program Manager
Artefactual Systems, Inc.
604-527-2056
@accesstomemory


--
You received this message because you are subscribed to the Google Groups "AtoM Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ica-atom-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ica-atom-users/0c7f0c28-b850-4ff9-aa0c-07ebce99ab58%40googlegroups.com.

Stef Emiljanowicz

unread,
Jun 3, 2019, 2:20:59 PM6/3/19
to AtoM Users
That's brilliant Dan and looks very promising... I'll certainly give it a try. Thanks!
Stef
To unsubscribe from this group and stop receiving emails from it, send an email to ica-ato...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages