Forum for discussing general topics related to Couch.
17 posts Page 2 of 2
Nope, wrong. I didn't get it after all.

This does not work:

Code: Select all
<script>var langshop = getCookie("toggleLanguage");</script>

<p>|<script>document.writeln(langshop);</script>|</p>

<cms:set toggleLanguage = <cms:get_cookie 'toggleLanguage' /> />
<p>[<cms:show toggleLanguage />]</p>
<cms:if toggleLanguage = 'German' >
<cms:set language = '7' />
<cms:else />
<cms:if toggleLanguage = 'English' >
<cms:set language = '0' />
<cms:else />
<cms:set language = '8' />
</cms:if>
</cms:if>

<cms:show language />


So, how do I do to get the cookie to a variable???
Code: Select all
<cms:set toggleLanguage = "<cms:get_cookie 'toggleLanguage' />" />
<cms:show toggleLanguage />

Does this help?
Yes, it does, thanks.

But it works only for the French (original) page.

I got this code to test

Code: Select all
<script>var langshop = getCookie("toggleLanguage");</script>

<cms:set toggleLanguage = "<cms:get_cookie 'toggleLanguage' />" />
<cms:if toggleLanguage = 'German' >
<cms:set language = '7' />
<cms:else />
<cms:if toggleLanguage = 'English' >
<cms:set language = '0' />
<cms:else />
<cms:set language = '8' />
</cms:if>
</cms:if>

<p>Cookie: <script>document.writeln(langshop);</script> |
Code Couch: <cms:show toggleLanguage /> |
Code language: <cms:show language /></p>


on the page:
https://www.pauloeuvreart.org/reproductions_artiste/50-tableaux-celebres/le-baiser-par-gustav-klimt.html

It works well.

French.jpg
French
French.jpg (111.77 KiB) Viewed 8505 times


But as soon I change language, it disappear, and I get only the result by default (8 for French).

German.jpg
German
German.jpg (125.1 KiB) Viewed 8505 times


It is really strange. Even if the cookie wasn't there, the paragraph markup would not disappear.

????

I am contacting the plugin company, might be on their end.

Any other idea what might cause this?

Cheers,
Paul
Ok, I modified the punctuations to

Code: Select all
<cms:if toggleLanguage = "German" >


but Couch see the cookie in French only.

English.jpg
English
English.jpg (66.62 KiB) Viewed 8505 times
This code works, but there's definitely a caching problem.

How can I use caching only for checking cookie?
Like the emails?

Code: Select all
<script>var langshop = getCookie("toggleLanguage");</script>
<cms:no_cache />
<cms:set toggleLanguage = "<cms:get_cookie 'toggleLanguage' />" />
<cms:if toggleLanguage = 'German' >
<cms:set language = '7' />
<cms:else />
<cms:if toggleLanguage = 'English' >
<cms:set language = '0' />
<cms:else />
<cms:set language = '8' />
</cms:if>
</cms:if>
@PaoloE, I had a look at the issue and found the following to be the issue -

1. Cloudflare is aggressively caching the page output so any Couch tags are effectively executed only once and the same output is then served to all users. Please note - <cms:no_cache/> will have no effect here because Couch is not involved in this caching at all.

2. This is also related to the point above - anytime a language is selected, the page refreshes and the page URL changes to reflect the language e.g. becomes https://de.pauloeuvreart.org/ or https://en.pauloeuvreart.org/ depending on the language.
For cloudflare the entire domain changes and it starts serving previously cached pages for the new domain.

In short, I don't quite see how Couch can help in this scenario where everything is so heavily cached (I realize the site takes heavy traffic and turning off Cloudflare caching is not an option).
Well, I wish there was heavy traffic...

Ok, I will figure out something. Now that PHP is out as well as Couch, if will JavaScript the shit out of it.

There is a first for everything... ha ha.

Thanks KK
17 posts Page 2 of 2