Package: visaplan.plone.ajaxnavigation
Add AJAX navigation to a Plone site.This is probably not the most advanced or state-of-the-art way to add AJAX
navigation; for Plone 5, I was told aboutplone.patternslib, based onpatternslib.ForVoltosites, the whole jQuery-based handling might be obsolete because
of the use ofReact.js.At the time of this writing, those were no options for me since I was still on
Plone 4.3.  Thus, I needed a working solution.
Depending on the quality, I’ll switch to some Plone-5-ish solution when doing
the leap, or I’ll stick with my own.The general idea is:Catch theclickevent for everyaelement on the page.For some links, a special check will tell to proceed with the standard
behaviour, i.e. load the target the standard way; this includes:Link targets outside of the current site (another hostname is given)Management pages (e.g. starting withmanage_)Other pages which don’t load the navigation links etc. anyway,
or wouldn’t work when loaded via AJAXAnchor elements with certain attributes (data-fullpage-only="true")Views for contexts which don’t have a suitable embedable view yet.For such link targets, this function will simply returntrue,
and the page is loaded in the standard way.If that check function concludes, “let’s load the target via AJAX”,
it will send a request to an.../@@ajax-navaddress which will return
all necessary JSON data; using the result,
it will look for certain elements on the page and try to update them:#content(the target forcontentas of the default configuration)and, optionally:breadcrumbsother page elements, like context specific search forms.It will also set the page url and title accordingly
(from the@urland@titlekeys of the JSON reply, respectively),
allowing for the browser history.If the tried URLs fail to return a usable JSON answer,
or if the target URL is inappropriate for other reasons
(e.g. page-local, or leaving the current site),
the target page is loaded the normal, non-AJAX way
(i.e., loading the whole page).All hyperlinks willcontinueto work with Javascript switched off;
of course, pages will load faster when switched on.FeaturesTries up to two URLs for eachaelement (only one, if the target URL ends
with “/”, or if the final path element can be considered a view method
name rather than an object id)Can be configured using the Plone registry:targetattributes ofaelements are regardedby default,
following thePrinciple of Least Surprise.
However, you are encouraged to disregard them, since the use of this
attribute is not recommended.By default,a[target]elements are secured by adding to them arelvalue ofnoopener.To doUse aweb worker.Make this packageRequireJS-aware.Provide support for additional search configurations.Pick values from contents to be replaced, and re-insert them
(e.g. search expressions in context specific search forms).ExamplesThis add-on is currently under development and not yet used on public internet
sites.DocumentationFull documentation for end users can be found in the “docs” folder.InstallationInstallvisaplan.plone.ajaxnavigationby adding it to your buildout:[buildout]

...

eggs =
    visaplan.plone.ajaxnavigationand then runningbin/buildout.Or, more likely:Add it to the dependencies of your package, e.g. in yoursetup.pyfile.You’ll need to provide@@embedviews for your content types;
ideally, you can use your already-existingBrowserViewclasses.
Usually it will be sufficient to make a copy of yourviewtemplate
and inject anajax_load=1request variable.Questions“Why don’t you simply inject thatajax_loadvariable
automatically per BrowserView code?”Yes, we do so already.There is a simple.views.AjaxLoadBrowserViewclass which takes care of
this, and a few subclasses.“Why don’t you drop thatembedview name, and simply useview,
withajax_load=1injected?We do so as a fallback option.
But some of our pages simply don’t work this way
(e.g. because some necessary scripts are loaded in a METAL slot
which is dropped ifajax_loadis found true),
so we need to be able to be explicit.Thus, an..._embedview is used, if present, and then the standard view
jumps in as a fallback.The visaplan.plone.ajaxnavigation package was developed as a drop-in solution
for sites which might not do everything right already.
If your site works fine withajax_loadinjected, you’ll need to do less
customization work to make it run.Quite probably there are several things which could be done better.
Contributions are welcome.ContributeIssue Tracker:https://github.com/visaplan/plone.ajaxnavigation/issuesSource Code:https://github.com/visaplan/plone.ajaxnavigationSupportIf you are having issues, please let us know;
please use theissue trackermentioned above.LicenseThe project is licensed under the GPLv2 (or later).ContributorsTobias Herp,tobias.herp@visaplan.comChangelog1.0.0.3 (2020-03-06)Hotfixes due to customization problems
(for internal use).[tobiasherp]1.0.0 (2020-03-06)Initial release.
[tobiasherp]