ryan

New MarkupCache module

Recommended Posts

Using MarkupCache and needed to switch the page to MultiLanguage. First I thought oooh my god how can I achieve this without having code duplications within complex conditions?!  :undecided:

But it's PW (in this case it's just PHP logic^^) but PW is great! :D

You "only" have to set the name of the cache file dynamically based on the language. Nothing easier than that.

Just replace the normal initialization of the cached section from

<?php if(!$data = $cache->get("something")) {

to

<?php if (!$data = $cache->get("something_lang-{$user->language->name}")) {

Then, assuming whe have 2 languages, default and de, it's generating one cache file called "something_lang-default" and "something_lang-de"

of course you can set the name format to whatever you prefer ;)

Just wanted to share my achievement for everyone else looking for MarkupCache on a multi language site

cheers

Can

  • Like 1

Share this post


Link to post
Share on other sites

Ryan, is there any particular reason why this module is singular? (Or better question: could it not be?)

I think that blocks nested caching (which is @Hari's problem as well, I think).

Thanks.

Share this post


Link to post
Share on other sites

@pwFoo

  • MarkupCache only supports strings and uses files for storage.
  • WireCache supports arrays (of non-objects), PageArray and strings and uses DB for storage. 

WireCache is the way to go.

  • Thanks 1

Share this post


Link to post
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


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By thuijzer
      https://github.com/thuijzer/processwire-FieldtypeBusinessHours
      Fieldtype Business Hours
      ProcessWire Fieldtype for entering business hours (opening hours)
       
      Input format
      Leave a day empty when closed on that day
      Times are in 24 hour format.
      9:00-12:00 9:00-12:00, 13:00-17:30 16:00-2:00  
      Usage in templates
      Days are from 1 to 7 where 1 is Monday and 7 is Sunday (ISO-8601)
      echo $page->field_name->isNowOpen() ? 'Now open' : 'Now closed'; if($page->field_name[1] == null) { echo 'Closed on Monday'; } if($page->field_name[2]->inRange('11:00')) { echo 'Tuesday at 11:00 open'; } echo $page->field_name[1]; echo $page->field_name[1]->entries[0]->getFrom()->format('H:i');  
    • By adrian
           Tracy Debugger for ProcessWire
      The ultimate “swiss army knife” debugging and development tool for the ProcessWire CMF/CMS
       

       
      Integrates and extends Nette's Tracy debugging tool and adds 30+ custom tools designed for effective ProcessWire debugging and lightning fast development
      The most comprehensive set of instructions and examples is available at: https://adrianbj.github.io/TracyDebugger
      Modules Directory: http://modules.processwire.com/modules/tracy-debugger/
      Github: https://github.com/adrianbj/TracyDebugger
      A big thanks to @tpr for introducing me to Tracy and for the idea for this module and for significant feedback, testing, and feature suggestions.
    • By Harmen
      Hello all,
      Was wondering if any of you tried to include the Exact PHP client by Picqer in Processwire (URL)? I am trying to at the moment but I am stuck at the Authorization process. Building it inside a module file to execute a certain function every 6 hours to update something on the website. For the authorization process the file has to execute the following piece of code:
      header('Location:'. $urlThatRedirectsMeToTheLoginOfExact); But each time I am trying  to do so, I get the following error: Cannot modify header information - headers already sent by (output started at /processwire/index.php:55). I am out of options so that's why I am trying to find someone who used this library and could get it to work or someone who knows how I can fix it.
      Tips are highly appreciated (if they work ;))
      Cheers, Harmen
    • By BitPoet
      So I stumbled over the request to allow limiting templates to be used only once under every parent page in this thread
      and found that this would actually come in handy (also in a site I've built).
      The code can be found on github and soon also in the module repo.
      After installation, you'll find a new checkbox "Only once per parent" in the family tab when editing a template.