Note that there are some explanatory texts on larger screens.

plurals
  1. POPrestashop: switch theme on the fly and read cookie to check param in url
    primarykey
    data
    text
    <p>In order to setup an A/B testing (through GG Analytics), I planned to duplicate my current theme (for organisations purposes) in order to use the duplicated theme to do the alternate versions of the test. I use <code>Prestashop 1.4.9.2</code> .</p> <p>What I already did, and works:</p> <hr> <p>Added this to <code>/classes/FrontController.php</code>, in <code>displayHeader()</code> function <em>(I know I should override, but not the point ;))</em>:</p> <pre><code>if(isset($_GET['alternate'])) { $cookie-&gt;alternate = "1"; $cookie-&gt;write(); } </code></pre> <hr> <p>Replaced in <code>/config/settings.inc.php</code> :</p> <pre><code>define('_THEME_NAME_', 'my_usual_theme'); </code></pre> <p>by</p> <pre><code>if(isset($_GET['alternate']) || $cookie-&gt;alternate == "1") { define('_THEME_NAME_', 'my_alternate_theme'); } else { define('_THEME_NAME_', 'my_usual_theme'); } </code></pre> <hr> <p>This way, when I load my Prestahop url with "<code>?alternate</code>" at the end, it loads the alternative theme. Fine.</p> <p><strong>PROBLEM</strong>: I can't check the cookie value in <code>settings.inc.php</code>, and so when I click a link, it loads the default theme.</p> <p><strong>QUESTION</strong>: Any clue to check the cookie in this file ? Or <code>config.inc.php</code> ? Or "re-define" the theme name in another file, overriding the <code>settings.inc.php</code> setup ?</p> <p>Please note I check the cookie in another single file to validate the process, and it works well. I also tried to use classic <code>setcookie</code> method, but if I can read/check, I can't write with this way... And for a reason I don't get, PHP activation in Smarty just don't work (tried to <code>setcookie</code> directly in template, but error 500 even with a simple echo).</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload