0

My organization is using an external search application. The results are intended to be wrapped in a header and footer to mimic the appearance of the main website.

I've created a couple of custom routes, /wrapper/header and /wrapper/footer, that simply return a (practically) empty page with a partial template. As far as the markup goes, that's working fine; the search app can pull both and wrap them around the results as intended.

However, on the header, we need to use full URL for the aggregated CSS and JS files. I've taken a look at hook_page_attachments_alter(), but that appears to deal with assets attached pre-aggregation. Is there a way for me to override the URLs inserted to replace the placeholders? The CDN module looked promising, but can't be restricted to work on specific routes.

2
  • How are you defining those external css/js files ? have you tried defining them as external ? drupal.org/docs/8/creating-custom-modules/…, here is another example drupal.stackexchange.com/questions/192606/…
    – GiorgosK
    Mar 19, 2019 at 22:23
  • I'm not defining them -- they're the same assets being used by all the other pages. The problem is that the search app is running on another server, under a different domain, so while we want it to use the same assets, it needs the full URL in order to load them. I expect the search side could find and alter the strings, prepending the protocol and domain to the URLs after retrieving the code, but I was hoping to retain control over that on the Drupal side.
    – WRD
    Mar 21, 2019 at 14:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.