Jump to content

Ideas for customizing blocks of a procache website


bernhard
 Share

Recommended Posts

Hey all! 

I want to rebuild my personal website in the near future.. I thought it might be nice to serve my content as targeted to my audience as possible. In German we have the informal "DU" and the formal "SIE". I'd like to give visitors the option to choose whether they want to be addressed formal or informal. 

Depending on their choice, I'd serve content like "schön, dass SIE DA SIND" or "schön, dass DU DA BIST". I wonder some things though... 

How would I tell procache to serve either one or the other phrase based on a cookie (or something else?)? 

How would I do that properly to not ruin my seo? 

Any ideas welcome. It's a brainstorming post, thx ?

Link to comment
Share on other sites

JavaScript ?

The easy way out would be to include both phrases (possibly one as a default and other as data-attributes or something similar), and then switch those as needed. You could also fetch entire blocks based on user selections, but that would result in some overhead.

Alternative would be to set a variable in .htaccess based on cookie value, and then modify the ProCache rules to serve files from another directory. In this case, though, you'd likely need to use hooks in order to make ProCache store (and clear etc.) two different versions. This approach seems a bit over-complicated for my taste ?

  • Like 2
Link to comment
Share on other sites

If you're content using just the template cache instead of ProCache, you could do this with my Cacheable Placeholders module, which is designed for exactly this purpose: Having a fully cached site with just some dynamic placeholders which are dynamically replaced. You can add a placeholder wherever you want to output some content with Du / Sie variations and use the callback to server the correct output depending on the cookie value (or whatever). Won't work for ProCache though, as it can't modify the static HTML pages.

But if you want to use ProCache, yeah, JavaScript probably. I recently had a similar problem on schwarzdesign.de. The dynamic options there include the theme switch (light / dark theme), as well as the Fridays for Future theme, which is only displayed on friday (use this link to view the theme even if it's not friday ?). Previously, this was done server side by reading a session value which stored the theme preference as well as checking if it's friday and serving the corresponding stylesheets / body classes. In order to be able to use ProCache, I have rewritten that functionality in JavaScript. Now both scripts are included as preloads, and the correct theme is toggled active with JavaScript depending on the stored preference (now using localStorage instead of the session). Maybe you can do something similar, but with JSON files containing translations, and then replacing the texts with JavaScript? You can check out the source code on schwarzdesign.de, it's an inline script in the <head> section, pretty simple in this case. As for SEO, I would definitely serve one version by default (maybe the formal language version) and then just replace it with the information version with JavaScript, if selected ... this way it shouldn't impact your ratings negatively.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...