Download the PHP package doublesecretagency/craft-siteswitcher without Composer

On this page you can find all versions of the php package doublesecretagency/craft-siteswitcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package craft-siteswitcher

Site Switcher plugin for Craft CMS

Easily switch between sites on any page of your website.


This plugin provides an easy way to switch between sites on your website. Regardless of which page you are currently on, you will be linked to the same page in its parallel site.

* Note: You must be using Craft's multi-site feature to access multiple languages on your website.


The Twig Function

Returns a URL which links to the alternate-site version of the current page. If the siteHandle or element is invalid, false will be returned instead.

Basic Usage

Simply use a line of code like this:

That will link you to the Spanish version of the current page.

Advanced Usage

If the current page is an entry, your entry might be using different slugs for each language. In that case, you can pass the entry object as your second parameter:

That second parameter can accept any Craft element type, so you can use other elements as well! Obviously, only elements which make use of slugs (like category elements) will work.

Sharing site links between entries & non-entries

Using the null-coalescing operator, you can chain potential element types. If one isn't defined on a particular page, the next value will be used.

This will use the first non-null value it finds (or null if no element exists).


In Conclusion

A simple piece of code like this one will work great across 99% of sites:

You can use this code in an include, and share it across your entire website. If the page is an entry page, it will use the localized version of that entry's slug. Otherwise, it will simply retain the same URI for each link.

Dynamically looping through all sites

If you want to dynamically loop through each of your sites, try this instead:

Checking whether a translated element exists

You can check to make sure that a translated version of that element exists before showing the link:

Fall back to the translated homepage

Assuming your homepage is properly translated across each site, you can set the homepage as a final backstop. If the link cannot otherwise be determined, it will link to the translated homepage instead.

Simply set the optional third parameter to true:


Anything else?

We've got other plugins too!

Check out the full catalog at doublesecretagency.com/plugins


All versions of craft-siteswitcher with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^5.0.0-beta
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package doublesecretagency/craft-siteswitcher contains the following files

Loading the files please wait ....