LiveChat.OrchardCore is an Orchard Core CMS Module that provides the necessary settings to add script code from your live chat service to the website.
Add the NuGet package, LiveChat.OrchardCore, to the Orchard Core CMS Website. Launch the website and sign in as an administrator to enable the module from the dashboard under Configuration -> Features.
Add the script code from your live chat service to the settings area provided by the module, Configuration -> Settings -> Live Chat.
Make sure you check Enable to activate live chat and click Save to save the settings.
Visit the front-end of your website. The script code will be injected at the bottom of every non-admin page just above the closing body
tag.
If your live chat service is not displaying on the website, here are some common problems.
- Incorrect Script Code: Please double-check the script you entered into settings is correct and your live chat service is active and configured properly.
- Live Chat Not Enabled: The Enable checkbox allows you to turn on and off live chat without removing the code. Make sure you have checked Enable.
- Missing FootScript from Theme Layout: The script code is injected into the website using Orchard Core's
ResourceManager
. Verify your theme's layout is injecting resources of typeFootScript
.
See the Orchard Core Documentation for more information on Resources.
The module is easily customizable. Here are a couple possible customizations depending on your needs.
If you prefer your live chat script be added within the head
tag of the page instead of before the closing body
tag, you can change the LiveChatFilter
code to inject the code as HeadScript.
// _resourceManager.RegisterFootScript(content);
_resourceManager.RegisterHeadScript(content);
Many third-party plugins ask for a code, instead of a script, from the live chat service. These plugins are usually specific to a certain service and a bit more fragile since they need to be updated when the script they embed changes. Asking for a script avoids frequent updates and allows the module to support multiple live chat services.
However, you can modify the module to request a code in settings instead of a script by changing LiveChatSettings.Edit.cshtml
. You can then embed the live chat service's script in the module and generate the script using the code before the call to _resourceManager
.
var code = new HtmlString(settings.Text);
var content = GenerateScript(code);
_resourceManager.RegisterFootScript(content);
There is 1 planned enhancement:
- Caching: Caching will be implemented using
IMemoryCache
.
LiveChat.OrchardCore is created and maintained by David Hayden.