Jump to content

Recommended Posts

Posted

Hi guys,

I'm trying to create a quote of the day Pages block to show at the home page. I have a Pages database with many quotes already and I'm able to visualize on my home page one quote.
However, the block refreshes whenever caching time is over and I want it to refresh the text and pull a random quote one time per 24 hours only.
In previous versions of IPS it was possible to control the caching time per block, but now it is not as long as I see. Is this correct?

How can I somehow make it refresh only one time per 24 hours / day? Any extra code to put in the template for the block or something? 
Or any other suggestions to make this work preferably via a block?

Posted
3 hours ago, Matt said:

You'll need to do the caching/refresh logic inside the block itself if you want more control over how long the item is cached for.

Thank you very much for your reply, @Matt!

Can you provide some further guidence for this? Any sample code?

Anything I can simply copy/paste + eventually do small modifications to make it work?

Posted

We cannot assist with custom development as part of support unfortunately. It would require for someone to look how, code this, test etc, which is not something we can cover as part of support. I have moved this ticket over to our development forums, as there may be others who have done the same.

  • Management
Posted

It really depends on how you have structured your database and code.

There are areas of the software that we manage caching independently of the rest of the suite, and when we do this, we typically store the data like so:

\IPS\Data\Store::i()->yourDataKey = [ 'time' => time(), 'data' => [ ... your data here ... ];

Then when reading you can check 'time' against the current time and make a decision as to whether to use the data or refresh it.

For an example of this, check out /system/Widget/Widget.php, around line 879

  • Recently Browsing   0 members

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