Feb 24 2009 Tuesday, 1:30 pm
ICT Bersama Sirman
Random posts for blogger/blogspot
salam en.sirman..cikmin nak tanyer la..camner nak buat random post tu…?eh..soklan camni leh tanyer ke…try je la ek…
————————————————————————————————-
Sirman said:
dengan menggunakan tahap tertinggi googling skills, sy berjaya menemui an alternative bagaimana nak buat “Random posts for blogger/blogspot“
cth leh tgk kat blog sy atas kiri. gerek dak? 8)
senang jer nak buat, just 2 steps jer:
1. Add a Gadget from your Page Elements (cth gbr bwh).
Pilih HTML/JavaScript & paste code bwh ni:
<div id="extract_output">
</div>
1st gadget ni terpulang kat korang nak letak kat mana, so kat mana u letak kat situ la munculnya random posts tu nanti.
2. add the 2nd Gadget from your Page Elements. Tapi kali ni move gadget tu ke bwh sekali. (cth gbr bwh)
pastu paste code ni lak:
UPDATE 4:30pm
seems that code bwh ni dah mess up, tu yg tak jadik tu :[
so please download dr sini:
http://redmummy.com/downloads/ict_bersama_sirman_random_posts.txt
<script type=”text/javascript”>
/*<[CDATA[ <!– */
//Beginning dynamic archive extract code.//Locate the archive list.
var archive = document.getElementById(“ArchiveList”);
var archive_html = archive.innerHTML;
var links = [];var introArray = new Array(
“<br>Have you read ^?”,
“<br>Check out ^.”,
“<br>Looking for something to read? How about ^.”,
“<br>My blog says: \”Look at ^\””,
“<br>I dredged up an old post just for you: ^”,
“<br>Please look at ^.”,
“<br>I wonder if you’d like to read ^?”,
“<br>You might enjoy reading ^.”,
“<br>Look what I found for you: ^”,
“<br>My blog has a post just for you: ^.”
)//Now search for child elements that have the class “posts”
//These contain the links that we want to extract.function random_number(range)
{
return (Math.round(Math.random()*200000)%range);
}var found_place = archive_html.search(‘<‘);
while(found_place!=-1)
{
var extract_string = archive_html.substring(found_place,found_place+10);//Check to see if we found the beginning of the link section we want.
if(extract_string.localeCompare(“<ul class=”)==0|
extract_string.localeCompare(“<UL class=”)==0)
{
//Found the link list, now go through and extract the links.
var inner_search = archive_html.search(“<“);
if(inner_search==-1)
{
links[links.length]=”(Failed)”;
exit;
}
var loop_flag = true;
while(loop_flag)
{
if(inner_search==-1)
{
exit;
}
else
{
if(archive_html.substring(inner_search,inner_search+5).localeCompare(‘</ul>’)==0|
archive_html.substring(inner_search,inner_search+5).localeCompare(‘</UL>’)==0)
{
//Finished with this archive section so exit.
loop_flag = false;
}
else if(archive_html.substring(inner_search,inner_search+2).localeCompare(‘<a’)==0|
archive_html.substring(inner_search,inner_search+2).localeCompare(‘<A’)==0)
{
//Found a link to extract, now find the end of the link.
var end_link = archive_html.search(“</a>”)+4;
if(end_link==3) //Returns negative one if fail, so +4 becomes 3.
{
//Must be Internet Exploder, do a capital search.
end_link = archive_html.search(“</A>”)+4;
}
//Do the slice
links[links.length] = archive_html.substring(inner_search,end_link);
}
}
//Cut out opening just found.
archive_html = archive_html.substring(inner_search+1);
//Search again.
inner_search = archive_html.search(‘<‘);
}
}//Trim out the opening we just found.
archive_html = archive_html.substring(found_place+1);
//Search again.
found_place = archive_html.search(‘<‘);}
//Great, now we have a list of links from the archive
//Do something with them.document.getElementById(“extract_output”).innerHTML =”;
var number_of_links = 5;for(var counter=0; counter<number_of_links; counter++)
{var output_string = introArray[random_number(introArray.length)];
output_string = output_string.replace(“^”,links[random_number(links.length)]);
//Pick a random link and put it in the output area.
document.getElementById(“extract_output”).innerHTML += output_string;
}/* ]]> –> */
</script>
pastu save la & jeng jeng jeng dah siap! 🙂
kalo nak customize kan leh gak, cam all those sentences tu kan, boleh la tukar mengikut selera masing2.
“<br>Have you read ^?”,
“<br>Check out ^.”,
“<br>Looking for something to read? How about ^.”,
“<br>My blog says: \”Look at ^\””,
“<br>I dredged up an old post just for you: ^”,
“<br>Please look at ^.”,
“<br>I wonder if you’d like to read ^?”,
“<br>You might enjoy reading ^.”,
“<br>Look what I found for you: ^”,
“<br>My blog has a post just for you: ^.”
then yg ni plak
var number_of_links = 5;
5 = number of random posts yg korang nak, nak buh 18 pun tak de masalah.
k good luck!
*** credits to Random Post Link Addon Script for Blogger
p/s: kalo utk wordpress lak korang kena install plugins Random Posts from here http://rmarsh.com/plugins/random-posts/
Redmummy said: tidak semua ICT Bersama Sirman is appeared in this blog, most of your questions kalo agak2 biasa je sirman akan jawab to your email directly.
Mrs Safwan
Feb 24, 2009 @ 13:43:57
Aaarghhhh.. .tak jadi pun….
ICT Bersama Sirman | StereoPropaganda
Feb 24, 2009 @ 14:00:29
[…] See the rest here: ICT Bersama Sirman […]
cikmin
Feb 24, 2009 @ 14:14:16
terima kaseh ye En.Sirman..cikmin try dulu….
cikmin´s last blog post..Tawaran Hebat Dari AIR ASIA…tunggu apa lagik…(sticky mode entry..sila scroll ke bawah untuk entry baru)
A N N
Feb 24, 2009 @ 14:20:41
I tried pun tak jadi – Nadhhhhhh tolong!!!!
A N N´s last blog post..Shoes entry!
CikPuanMuda
Feb 24, 2009 @ 14:59:12
ha’ah.. tak jadik pun… buta IT sungguh saya ini
CikPuanMuda´s last blog post..Impian kecundang
attyfir
Feb 24, 2009 @ 15:02:58
gud info.nanti senang leh torai..
attyfir´s last blog post..Continued Story..
Diana-k
Feb 24, 2009 @ 15:30:58
aiyak..tak jadik aaaaaaaaa bro!
awat ehh….
😆
Diana-k´s last blog post..#Not so-smart tunnel#
strawberi
Feb 24, 2009 @ 16:07:05
tak publish pun tkpe…ehehe..salam
nk tanya..utk ad large rectangle…katne nk paste code..dh paste mcm2 tmpt kat html code..tk appear2 pun kat blog..
so far..dh ade 2 leaderboard n skycraper..igt nk tambah large rectangle..tp taktau nk tambah kat ner…blurr dh..tq
ashterix
Feb 24, 2009 @ 17:05:26
@strawberi,
dah try steps ni http://www.nuffnang.com.my/blogger/blogspot
cikmin
Feb 24, 2009 @ 16:36:05
x jadik la pulak…
cikmin´s last blog post..Tawaran Hebat Dari AIR ASIA…tunggu apa lagik…(sticky mode entry..sila scroll ke bawah untuk entry baru)
ashterix
Feb 24, 2009 @ 17:00:17
all,
ade copy & paste error tadi. so sy dah update post ni.
sila copy paste balik both codes. kompom jadik! 🙂
RedMummy
Feb 24, 2009 @ 17:01:37
@ashterix,
tu arrr
orang cakap tak caya!
A N N
Feb 24, 2009 @ 17:16:23
@RedMummy,
takpe Sirman, dont lose hope & be demoralise! Check lagi then teach us again. So jgn layan Desperate Housewives Season 5, tu you KIV dulu until this one dah settle!
A N N´s last blog post..Shoes entry!
RedMummy
Feb 24, 2009 @ 17:18:56
@A N N,
our season 5 is almost finished kak 🙂
hehehehehe
pastu freeeeeee gioler memalam…
zizilala
Feb 24, 2009 @ 17:29:15
mcm best jek info ni.. nnt nk try ler.. 🙂
zizilala´s last blog post..Pokok Celaka vs M.A.B
A N N
Feb 24, 2009 @ 17:51:55
ok done, macam dah boleh even thou halfway je, part ‘var_links’ tu tak buat pasal dah pening. That one I continue later!
Thanks Hang Sirman!!
A N N´s last blog post..Shoes entry!
cikmin
Feb 24, 2009 @ 18:02:16
tenkiu EN.Sirman ye…. 😉
cikmin´s last blog post..Tawaran Hebat Dari AIR ASIA…tunggu apa lagik…
Fad Ariffin
Feb 24, 2009 @ 19:59:29
yayy! jadik! jadik! tapi… sy tak nak pakai all those sentences tuh, tak nak pakai introArray. Try2 gak tadi buang edit sana sini, at last jadik jugak.
TQ TQ TQ En. Sirman.. 🙂
Fad Ariffin´s last blog post..PGLtM III – PEMENTASAN TERHEBAT!!
cikponbopbon
Feb 24, 2009 @ 21:10:57
tahap tertinggi googling skills tuuuuuu
heeee
cikponbopbon´s last blog post..The kecik : Daddy
strawberi
Feb 25, 2009 @ 08:51:18
waa..tenkiu..tenkiu..tk pasan ade dh kat nuffnang..tq mr ict
kui
Feb 27, 2009 @ 19:01:31
wah tq2..nak test sat gi
kui´s last blog post..dark side vs white side…hiyah p(^^)q
NathanKP
Feb 27, 2009 @ 23:34:48
Thank you very much for giving me credit for the script. I hope that it can be of use to everyone!
Nathan – Inkweaver Review
NathanKP´s last blog post..One Year Anniversary of Inkweaver Review
Dylan
Nov 01, 2009 @ 14:20:50
kalau nak buat ‘similar posts’ selepas every entry sirman tau tak?
.-= Dylan´s last blog ..My First DSLR! Canon 1000D =-.
RedMummy
Nov 01, 2009 @ 23:02:42
@Dylan,
dylan submit kat Contact Red pls
sirman will assist you from there