All Projects → charliedevelopment → craft3-fallback-site

charliedevelopment / craft3-fallback-site

Licence: other
Failing requests in a multi-site install can fall back to other sites, to prevent 404 errors from missing or disabled entries.

Programming Languages

PHP
23972 projects - #3 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to craft3-fallback-site

craft-react
Client and Server-side React rendering for CraftCMS
Stars: ✭ 40 (+185.71%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft-entry-instructions
A simple fieldtype to add instructions.
Stars: ✭ 16 (+14.29%)
Mutual labels:  craftcms, craftcms-plugin, craft3
Inlin-Craft
Plugin for inlining files in templates.
Stars: ✭ 64 (+357.14%)
Mutual labels:  craftcms, craftcms-plugin, craft3
visor
🕶 A simple admin overlay to get to the relevant areas of the Craft CMS control panel.
Stars: ✭ 25 (+78.57%)
Mutual labels:  craftcms, craftcms-plugin, craft3
Stamp-Craft
Plugin for adding timestamp to filenames.
Stars: ✭ 28 (+100%)
Mutual labels:  craftcms, craftcms-plugin, craft3
tags
A tag manager for Craft 3
Stars: ✭ 23 (+64.29%)
Mutual labels:  craftcms, craftcms-plugin, craft3
tablemaker
A user-definable table field type for Craft CMS
Stars: ✭ 39 (+178.57%)
Mutual labels:  craftcms, craftcms-plugin, craft3
molecule
⚛️ Grab Twig components, CSS and JS files outside the primary template folder
Stars: ✭ 20 (+42.86%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft-audit
Audit log for Craft 3
Stars: ✭ 18 (+28.57%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft-commerce-widgets
Insightful widgets for Craft CMS Commerce stores
Stars: ✭ 33 (+135.71%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft3-collections
Clean up those complex templates with Laravel Collections
Stars: ✭ 24 (+71.43%)
Mutual labels:  craftcms, craftcms-plugin, craft3
craft3-forms
This craft CMS 3 form plugin makes it easy to create and use custom forms with the features the Yii 2 Framework offers. On top of this, the plugin provides even more functionalities for easy implementation of forms in twig templates.
Stars: ✭ 20 (+42.86%)
Mutual labels:  craftcms, craft3
craft-router
A Craft CMS plugin for using URL segments as filtering criteria on an entry query.
Stars: ✭ 21 (+50%)
Mutual labels:  craftcms, craft3
store-hours
Manage business hours with Craft CMS.
Stars: ✭ 60 (+328.57%)
Mutual labels:  craftcms, craft3
Form-Builder
Craft CMS plugin that lets you create and manage forms for your front-end.
Stars: ✭ 16 (+14.29%)
Mutual labels:  craftcms, craftcms-plugin
formie
The most user-friendly forms plugin for Craft CMS.
Stars: ✭ 73 (+421.43%)
Mutual labels:  craftcms, craftcms-plugin
craft-select2
Filter / search a <select> using the popular Select2 fieldtype for Craft CMS
Stars: ✭ 18 (+28.57%)
Mutual labels:  craftcms, craftcms-plugin
craft-assetusage
Craft plugin adds a column to see which assets are used or unused.
Stars: ✭ 28 (+100%)
Mutual labels:  craftcms, craftcms-plugin
smartdown.craft-plugin
Bringing the unbridled joy of Markdown Extra and Smartypants to your Craft websites.
Stars: ✭ 26 (+85.71%)
Mutual labels:  craftcms, craftcms-plugin
events
Craft CMS Plugin for events management and ticketing.
Stars: ✭ 19 (+35.71%)
Mutual labels:  craftcms, craftcms-plugin

Fallback Site for Craft 3

This plugin allows each site to fall back to another site when a requested element cannot be found. This allows multi-site installations (typically for multiple languages) to gracefully fall back to existing content if available.

When a request is made for an element that would normally not be found, Fallback Site will check the configured site for an element with the same slug. For example, if you have an English site and a Spanish site as part of your craft install, and English is the fallback for Spanish, then handling for a request to the Spanish site would go as follows:

  • First, if an element was found on the Spanish site, everything continues as normal, and Fallback Site does not intervene.
  • If an element was not found on the Spanish site, Fallback Site checks if there is an English element with the same the slug.
  • If an English element is found, then that element's ID is used to see if there is a Spanish version available, which can happen if an incorrect, untranslated slug is used.
    • If a Spanish version exists, then a 301 redirect will be sent to the user, directing them to the correct URL.
    • If a Spanish version does not exist, then Fallback Site makes Craft use the English element in place of the Spanish one (With some conditions listed below).
  • If an English element is not found, then the request continues as a 404 as normal.

See the flowcharts below which demonstrate what happens when requesting a page, about-us, under a secondary, Spanish site (located at /es) within a multi-site Craft installation.

Normal Craft element handling

Craft routing without Fallback Site

Element handling with Fallback Site

Craft routing with Fallback Site

Requirements

  • Craft CMS 3.0.0-RC1 or above

  1. Open a terminal and navigate to your project folder:
cd /path/to/project
  1. Require the package to download it via Composer:
composer require charliedev/fallback-site
  1. Install the plugin on the Settings -> Plugins page in the Craft control panel.

--- or ---

  1. Install the plugin via the command line:
./craft install/plugin fallback-site

Configuration

Fallback Site settings panel

Within the Craft control panel, go to the Settings -> Plugins page, and then look for the Settings button listed by the Fallback Site plugin.

Here, you can select which site acts as a fallback for each other site. Fallbacks can also be chained across multiple sites, each site falling back to the next.

Usage

While the plugin works without any additional configuration, you may want to know if an entry being displayed has been substituted by Fallback Site. This may be done to display notices about the availability of site-specific content, or notify users of the replacement. Detecting this can be done by comparing the current site stored by Craft with the entry's associated site.

{% if craft.app.sites.currentSite != entry.site %}
	{# Entry content is coming from a different site. #}
{% endif %}
{# ... or ... #}
{% if craft.app.language != entry.site.language %}
	{# Entry content is in a different language. #}
{% endif %}

Built for Craft CMS by Charlie Development

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].