Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Themes available from a token into URLs #1787

Open
cara-tm opened this issue Feb 9, 2022 · 6 comments
Open

RFC: Themes available from a token into URLs #1787

cara-tm opened this issue Feb 9, 2022 · 6 comments

Comments

@cara-tm
Copy link

cara-tm commented Feb 9, 2022

Is your feature request related to a problem?

No!

What is the feature?

I don't know if it's possible: it will be very useful to have a kind of token added into the URL to serve a definite theme (maybe governed via "Preferences"). That feature could allow anybody to test a new website model (for clients, for online tools, for SmartPhones checking, etc.)

@Bloke
Copy link
Member

Bloke commented Feb 9, 2022

I'm confused. Setting a dev theme automatically shows the in-dev experience to anyone logged in. Usually, letting your client have a managing editor login allows them to see what's going on, and they can sign the changes off ready for go-live. If they sign in on different devices, that's the experience they see.

So you want some URL param to deliver the in-dev experience without being logged in?

@phiw13
Copy link

phiw13 commented Feb 9, 2022

@Bloke —Use case: I am (or the client / stakeholder / … is) logged in on a desktop computer and want to view the result on a small screen device. All the while editing the page(s) (text/element placement/design/…).

@Bloke
Copy link
Member

Bloke commented Feb 10, 2022

@phiw13 Yeah, that would be more handy than having to log in on a second device, which kicks you out of the desktop. I usually get round it with a pair of accounts. Not ideal.

I can't think of a simple way to do this, besides assigning each theme some unique hash (somehow) so you can tack that onto the URL and have it render the dev theme instead of the live one. It would have to be something unguessable, otherwise anybody could potentially see it.

@cara-tm cara-tm changed the title FR: Themes available from a token into URLs FRC: Themes available from a token into URLs Feb 10, 2022
@cara-tm cara-tm changed the title FRC: Themes available from a token into URLs RFC: Themes available from a token into URLs Feb 10, 2022
@cara-tm
Copy link
Author

cara-tm commented Feb 10, 2022

@Bloke

No worries. Just an idea. The reason why I said I don't think it's possible.

@jools-r
Copy link
Sponsor Member

jools-r commented Feb 12, 2022

The reason why I said I don't think it's possible.

@cara-tm Not necessarily the answer you are looking for, but might you be able to leverage parse_page() in combination with gps to do that?

Make yourself a temporary page template that serves as a switcher: it checks for your url variable and outputs either your new or old page_template. Something like this (untested):

<txp:php>
    if (gps('show') == 'new') {
        echo parse_page('template_name', 'newtheme');
    } else {
        echo parse_page('template_name', 'oldtheme');
    }
</txp:php>

Set that as your section's page template and then call https://www.yoursite.com/section-name/?show=new to see the new version. For easier surfing, save the setting to the browser's localstorage and check for that too (you'll then need a reset option to get back to the old template).

BTW: the PHPdoc function example here is lacking a value for 'theme'.


Aside: I sometimes use this method to route a page template through to another, e.g. error_401 -> error_default (for example, incorrectly answering a password_protect tag in debug mode causes the tag with password to show in the error notice! Adding an own error_401 template silences that. Using the following avoids you having to duplicate the whole template:

<txp:php>
    // Use the same page as error_default
    echo parse_page('error_default','');
</txp:php>

@cara-tm
Copy link
Author

cara-tm commented Apr 14, 2022

I tried but it doesn't seem to work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants