Problems, need help? Have a tip or advice? Post it here.
15 posts Page 1 of 2
I have a <cms:pages> tag, and I changed the orderby from 'publish_date' to 'random'. It works. But every time I click to that page, the first randomized order stays the same forever.

I had assumed that every time I click on the page, the order of blog posts shown would re-randomized anew.

I removed the "order='desc'" part of the pages tag just in case that was interfering somehow, but it didn't change anything.

Is orderby='random' supposed to randomize on each pageload? Or does it only randomize once per session or something like that?

Thanks to anyone for your thoughts.

I had assumed that every time I click on the page, the order of blog posts shown would re-randomized anew.

That is indeed how things should have worked.
As to why they are not, I am not sure but perhaps the caching has gone haywire somehow.

Please try emptying out the 'couch/cache' folder and see if this sets thing aright.
Do let me know.
Hi, KK. Thanks. I deleted the cache file in Couch's caches folder, but nothing changed.

I wonder if there's something screwy with how I'm triggering the randomization.

In the site I'm building, I've put up a menu link that says "Random post." I added a query string to that URL that looks like this:

<a href="blog.php?orderby=random" >Random Post</a>

When that link opens, <cms:php> reads the query string and sets a variable equal to 'random' which then gets inserted into <cms:pages>, like this:

<cms:pages masterpage='blog.php' custom_field='blog_category=Review' paginate='1' limit='10' orderby="<cms:show my_var_orderby />" order='desc' >

And so it is this "Random post" link that I'm clicking to get to my blog.php listing of posts in random order.

I don't supposed it could be the custom_field part of my <cms:pages> tag that's interfering?

I don't think custom_field would interfere with random.

Please make sure the correct value is being passed on to <cms:pages> -
place
Code: Select all
<h1>orderby: <cms:show my_var_orderby /></h1>

just before the <cms:pages> block and see what appears.

Also, is caching on (check couch/config.php)? If yes, try turning it off and see if that helps.

Please make sure the correct value is being passed on to <cms:pages>

Correct value is confirmed.

Also, is caching on (check couch/config.php)? If yes, try turning it off and see if that helps.

I double-checked. Caching is off (and has been for a long time).

Interesting behavior I'm seeing, however:

In Safari, the order of blog posts is re-randomized correctly if I load the URL into a New Private Window each time. But it doesn't work if I re-load the page into the same window, or into a new tab, or into a new window.

In Firefox, the order of blog posts is randomized correctly only one time per session if I open the page in a New Private Window. But opening more Private Windows and reloading the page doesn't work as it does in Safari. The order stays the same even in different Private Windows. The Firefox browser seems to remember the order from one private window to the next. (That's an interesting observation with respect to the efficacy of Firefox's "private window," isn't it? Or maybe my browser's hacked?

In any case, however, I also found that the order will re-randomize itself again, with either browser, if I wait long enough -- like 5 or 10 minutes. If I wait long enough (session expiry?), and I then load the blog.php page again in a new tab or window of any kind, it re-randomizes the order once again.

This makes it all seem like some kind of kind of session caching in the browser.

This makes it all seem like some kind of kind of session caching in the browser.

I agree; that would explain the behavior.

Let us then try and jump the cache by supplying a unique URL everytime the 'orderby' is set to random.
Please try something like the following to add a random value to the querystring -
Code: Select all
<a href="blog.php?orderby=random&rnd=<cms:php>echo time();</cms:php>" >Random Post</a>

Let me know if this helps.

Let us then try and jump the cache by supplying a unique URL everytime the 'orderby' is set to random. Please try something like the following to add a random value to the querystring - [...]


Great idea, and I thought that would do it. But there's no change in behavior at all. Curious. Interesting. If this mystery remains one, maybe I can force a random blog post anyway by resorting to <cms:php> and a <cms:query> in combo with the <cms:pages> call.

CORRECTION: I overlooked the fact that with the new RND query string, there were now two variables to evaluate, and I was only looking at 'random'by itself still. I'm implementing that now and will see if that fixes the problem. Back soon.


EDIT NEXT DAY: After I wrote the above "correction," I realized that there was no need for php to evaluate the RND querystring at all. That extra string was just to differentiate one URL from the next for the browser. Got a little confused, but all straight on that now.

It has nothing to do with browsers if cache of Couch is off.

OK, the result was this:

Even with the differentiated URLs, the problem has stayed the same; i.e, somehow, until a period of time expires (5-10 min maybe), clicking on the blog.php link won't re-randomize my blog posts. (Except in Safari, where opening the page inside a brand new Private Window does somehow allow immediate re-randomizing, no matter how quickly or how often I do it.)

Trendo: Thx. ... Maybe I'll try to force randomization via php and sql.

I wonder if that code is in a embedded snippet.. Couch does cache snippets separately in db.
15 posts Page 1 of 2

Who is online

In total there are 12 users online :: 1 registered, 0 hidden and 11 guests
(based on users active over the past 5 minutes)

Users browsing this forum: Google [Bot] and 11 guests