Recent Topics

1 Mar 23, 2007 23:06    

My b2evolution Version: 1.9.x

Hi,

with the random picture script I have found here in the forum it´s possible to display a random picture out of one of your blog postings with a link to the posting itself...

Due to the fact, that not every posting has pictures in it, I was asking myself if there already is a function in b2evo which would simply display a random posting title out of blog 2 or blog 3 or blog 2 and 3 which should of course be linked to the posting itself.

If there is no such direct possibility, I think I have to adapt the randpic hack somehow...

Thanks in advance...
Daniel

2 Mar 24, 2007 00:51

AFAIK, there's no "already-done" method of pulling up a random post.

One would THINK that it'd be as easy as finding the number of posts you've made and picking a random number between ONE and THAT NUMBER, but it's not. Reason: lots of posts end up in the dirt (unpublished, deleted, private, etc.) Can't pick those numbers.

Off the top of my head, it seems that the easiest way (conceptually), would be to query the database for all "published", "public" posts and put their post numbers into an array. Then find out how big that array is (+ indexing), then randomly pick a number from 1 to THAT NUMBER and make a link with http://yoursite.com/index.php?p=$RANDOM_NUMBER .

Should be loads easier than a random image linked to it's respective post. :D

Hope this helps.

3 Mar 24, 2007 17:13

Ah... hours after hours spending on trying to understand your random-image-in-sidebar trick and working out the code one line after the other using several sources explaining stuff (via google) I finally understand how this all works, have revised the script so that it is now working as I wanted to.

I think with this I´m now satisfied!

4 Mar 24, 2007 17:51

Yay! Good for you. I bet you learned some stuff! ;)

I'm glad that you were able to modify the code to get what you wanted. :D

5 Mar 24, 2007 21:41

Yeah... thanks very much for the whole idea and work; I only modified it for 2 reasons, first I coudln´t get your script working and second I nedded some litte changes, like the post title should be included etc..


Form is loading...