0

How can i stash content globally depending on https or http scheme?

One way is to store it under a context,
but then i have to change all stash set and get tags site-wide to work with a context parameter

{exp:stash:context name="{IS_SSL}"}

{exp:stash:set_list name="news" 
  save="yes" replace="no" refresh="30" context="@"
}
{stash:item_link}http://example.com{/stash:item_link}
{/exp:stash:set_list}

Without setting this context, the value would be stored once for 30 minutes, and served to everyone regardless of http scheme.

2

First thing to ask is, do you really need to? Your links could just be protocol relative:

{stash:item_link}//example.com{/stash:item_link}

If that's not the issue then you could create a global prefix in your config using Stash's config variable stash_var_prefix:

$config['stash_var_prefix'] = isset($_SERVER['HTTPS'] ) ? 'ssl:' : 'nonssl:';

(Note that a prefix followed by colon : is the same result as specifying a context="" on each tag individually.)

| improve this answer | |
  • In the end we ended up just serving https only. In the main index.php redirect if needed. Flushed the stash cache once, and only https content is served and cached now – GDmac Nov 10 '17 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.