{nocache}

Melih
Melih
@melih
10 years ago
198 posts
Can i use {nocache} in template for a single line?
I wanted to inform user that is there any unread private notes. But i think because of caches its not working properly.
updated by @melih: 01/26/15 04:41:44PM
brian
@brian
10 years ago
10,148 posts
Melih:
Can i use {nocache} in template for a single line?
I wanted to inform user that is there any unread private notes. But i think because of caches its not working properly.

Unfortunately no - Jamroom does not use Smarty's caching (which is file system based) but instead uses a DB cache.

If you can clarify where you're looking to put the check I can tell you if there is a way to do it.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
Melih
Melih
@melih
10 years ago
198 posts
Actually i tried something like this in the header menu:

{nocache}
{if {jrCore_db_get_item_key('jrUser', $_user['_user_id'], 'user_jrPrivateNote_unread_count')} > 0}Private Notes ({jrCore_db_get_item_key('jrUser', $_user['_user_id'], 'user_jrPrivateNote_unread_count')})
{else}
Private Notes (0){/if}
{/nocache}
brian
@brian
10 years ago
10,148 posts
The problem you will likely run into is that the page that that is within is going to be cached, and so even if you can get that small section to not cache, the outer page will be cached and so you won't see it change.

The real solution here is a bit more complicated:

1) Create a small custom module with a "view" of get_unread_note_count (or whatever) - views are NOT cached, but instead it's up to the module to handle it's own caching.

2) Create a Javascript function that runs an AJAX call that calls the view and returns the number of unread and updates the page

That's not hard to do, but is more involved than being able to do it at the template level.

It's got me thinking that have a core-provided solution for doing things like this would be a good idea, so I can check that out.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
Melih
Melih
@melih
10 years ago
198 posts
I am afraid its beyond my capabilities. I can do small things with my little knowledge :)
Until now i copied some here some there but making something like that seems not likely to me...
If you came up with solution core provided let me know please...
updated by @melih: 12/16/14 12:05:03PM
brian
@brian
10 years ago
10,148 posts
Melih:
If you came up with solution core provided let me know please...

Yep - I have it on my todo to check out and see if we can come up with something.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags