Ajax Content
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
Summary:
This drupal 8 module loads content with ajax. It converts internal links to ajax requests that return the rendered node. All attached JS and CSS of the requested nodes are also added and executed.
How it works:
This module uses D8 Core's bare page renderer to get the content of a node and attached assets as rendered HTML with fully aggregated JS + CSS scripts. The module converts internal links into ajax requests. These ajax requests return a rendered version of the node + js scripts + css files. It loads the data into a temporary iframe and then replaces the original page's main content region with the returned rendered html. The CSS is appended to the head tag. The js files are appended to the footer. Duplicate files replace existing ones.
Dependencies:
- Pathauto -> must be configured and producing aliases for all nodes you wish to link to via ajax.
Known Issues:
Currently only loads and replaces into one html container (can be chosen in the settings form at /admin/ajax-content/settings). Future releases should work with other regions as well.
Installation:
- Enable module
- Configure container div at /admin/ajax-content/settings. Depending on your theme, you will have to choose the right div container where the returned content will need to be loaded.
NOTE: Drupal 8's default Bartik theme does not play nice with this module. Although when enabled, if you click on an internal link you should see the ajax response and data populated in the correct location. The header and sidebar blocks break.
Testing:
- Create two nodes. Fill in their bodies with a decent amount of text. Include a link to the other node's pathauto url aliases.
- View the nodes and click on the links, the content should be loaded via ajax into the html container specified in the module settings (/admin/ajax-content/settings).
Demo:
https://southdakotatourismconference.com/
Issues:
If this module is of serious interest to others, please star it and send me feedback. This will incite me to improve its flexibility / configurability.