Cms: View site button in CP header dont support multisite

Created on 15 Jan 2021  路  2Comments  路  Source: statamic/cms

When multisite is enabled, and you have selected a site which is not the main site, the 'view site' button in the CP header always links to the URL of the main site in stead of the selected site.

I have tried to make a pull-request, but i am not sure if I had doing it right, so below the code to fix it. Has anyone a good tutorial for contributing to a github project?

OLD
/resources/views/partials/global-header.blade.php:56

<a class="hidden md:block h-6 w-6 p-sm text-grey ml-2 hover:text-grey-80" href="{{ route('statamic.site') }}" target="_blank" v-tooltip="'{{ __('View Site') }}'" aria-label="{{ __('View Site') }}">

FIX:
/resources/views/partials/global-header.blade.php:56

<a class="hidden md:block h-6 w-6 p-sm text-grey ml-2 hover:text-grey-80" href="{{ Statamic\Facades\Site::hasMultiple() ? Statamic\Facades\Site::selected()->url() : route('statamic.site') }}" target="_blank" v-tooltip="'{{ __('View Site') }}'" aria-label="{{ __('View Site') }}">
bug multisite

Most helpful comment

I've not got time to test it right now but it looks okay. You should even be able to make a pull request without the whole process of cloning everything down.

I've written a little tutorial of package setup (my example is Statamic Core) but it's not the easiest thing to understand 馃槄

All 2 comments

I've not got time to test it right now but it looks okay. You should even be able to make a pull request without the whole process of cloning everything down.

I've written a little tutorial of package setup (my example is Statamic Core) but it's not the easiest thing to understand 馃槄

Just tested it, works good. However, I'd probably not do a ternary and just do Statamic\Facades\Site::selected()->url() which works on both multisites and non-multisites.

Feel free to submit a pull request for it! I'm sure the team would accept it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jimblue picture jimblue  路  3Comments

ReneWeCode picture ReneWeCode  路  3Comments

AndreasSchantl picture AndreasSchantl  路  3Comments

jelleroorda picture jelleroorda  路  3Comments

aerni picture aerni  路  3Comments