boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

read more javascript hack
Goto page 1, 2  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
dodo



Joined: 25 Jan 2002
Posts: 35

PostPosted: Wed Apr 16, 2003 12:44 am    Post subject: read more javascript hack Reply with quote

this is a small hack. for those who likes the javascript extension of read more like movable type, here's the hack of how to do it.

demo here if you click on read more

first, you want to download this javascript file (right click and save target as). then open your b2template.functions.php in your b2-include directory and
find the line:
Code:

$output .= " <a href=\"$file?p=$id&more=1\">$more_link_text</a>";


and replace it with:
Code:

$output .= " <span id=\"varP$id\"><br /><a href=\"$file#$id\" onclick=\"showMore($id,'$file#$id');return false;\">read more »</a></span><div id=\"varXYZ$id\" style=\"display: none\">$content[1]<br /><a href=\"#$id\" onclick=\"showMore($id,0);return true;\">« hide more</a></div>";


save and reupload.

MAKE SURE you have
Code:

<script language="JavaScript" SRC="http://yourdomain/dir/oops.js"></script>

in your <head> and </head> or else it won't work.

then of course just like before, you write the "read more" entry with <!--more--> in b2.

that's how it worked for me. i hope it works for you, too. if not, hmm oh well.
_________________
http://pure-essence.net

b2 rocks
Back to top
View user's profile Send private message Visit poster's website
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Wed Apr 16, 2003 2:40 am    Post subject: Reply with quote

nice hack dodo =D thanks
_________________

++ GamerZ.Per.Sg - Complex Simplicity
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
mcgub



Joined: 19 Apr 2003
Posts: 27

PostPosted: Sat Apr 19, 2003 6:18 pm    Post subject: Reply with quote

That is sweet...nice work. Very Happy
_________________
7 out of 10 voices in my head say I'm not crazy
Back to top
View user's profile Send private message
bigsimon



Joined: 04 Jan 2003
Posts: 13

PostPosted: Sat Apr 19, 2003 6:40 pm    Post subject: Reply with quote

Okay.... what am I missing?

Code:
$output .= " <a href=\"$file?p=$id&more=1\">$more_link_text</a>";


This line of code doesn't exist in my copy of b2template.functions.php. I'm running the current release, too.
_________________
bigSimon
Back to top
View user's profile Send private message
mcgub



Joined: 19 Apr 2003
Posts: 27

PostPosted: Sat Apr 19, 2003 7:04 pm    Post subject: Reply with quote

Nope...me niether...I just went to the referenced site to see it...too bad we can't use it.
_________________
7 out of 10 voices in my head say I'm not crazy
Back to top
View user's profile Send private message
Cyberian75



Joined: 26 Sep 2002
Posts: 1283
Location: Oregon

PostPosted: Sat Apr 19, 2003 8:49 pm    Post subject: Reply with quote

I think you should look for this...

Code:

$output .= ' <a href="'.$siteurl.'/'.$file.$querystring_start.'p'.$querystring_equal.$id.$querystring_separator.'more'.$querystring_equal.'1#more'.$id.'">'.$more_link_text.'</a>';


...or something similar in "get_the_contents" function.
_________________
Michael P.

Back to top
View user's profile Send private message AIM Address
waterlilies



Joined: 21 Apr 2003
Posts: 3

PostPosted: Mon Apr 21, 2003 2:17 am    Post subject: Reply with quote

Cyberian75 is right. Find that code and replace it with this one:

Code:
$output .= '<span id="varP'.$id.'"><br /><a href="'.$file.'#'.$id.'" onclick="showMore('.$id.',\''.$file.'#'.$id.'\'); return false">read more »</a></span><div id="varXYZ'.$id.'" style="display: none">'.$content[1].'<br /><a href="#'.$id.'" onclick="showMore('.$id.',0); return true">« hide more</a></div>';


That should do the trick.
Back to top
View user's profile Send private message Visit poster's website
Candle



Joined: 23 Dec 2002
Posts: 547

PostPosted: Mon Apr 21, 2003 5:31 pm    Post subject: nice hack Reply with quote

wish they would have hacks like this for pmachine and easy like this to install .
_________________
My Game Forum
Back to top
View user's profile Send private message
epolady



Joined: 30 Jul 2002
Posts: 800
Location: Texas

PostPosted: Wed May 28, 2003 9:23 am    Post subject: Reply with quote

I really like this hack and find it very useful, but I had a question, Before I click "more" I have it set with one <br> (see screen shot), but after I click "more" and then click on "hide" it's coming up with 2 <br> (see screenshot).....any ideas?

Images removed

Here's what I'm using (I have oops.js uploaded and it's working fine) in b2templates.functions.php I have

Code:
$output .= " <span id=\"varP$id\"><br /><a href=\"$file#$id\" onclick=\"showMore($id,'$file#$id');return false;\">more »</a></span><div id=\"varXYZ$id\" style=\"display: none\">$content[1]<br /><br /><a href=\"#$id\" onclick=\"showMore($id,0);return true;\">« hide</a></div>";


Last edited by epolady on Sun Jun 01, 2003 8:07 am; edited 1 time in total
Back to top
View user's profile Send private message
waterlilies



Joined: 21 Apr 2003
Posts: 3

PostPosted: Wed May 28, 2003 10:11 pm    Post subject: Reply with quote

All I can tell you is that there are two <br> tags in your code after the $content[1]. That's the only thing that's different from your code and the one on Dodo's site.
Back to top
View user's profile Send private message Visit poster's website
epolady



Joined: 30 Jul 2002
Posts: 800
Location: Texas

PostPosted: Thu May 29, 2003 2:34 am    Post subject: Reply with quote

Hi, thank you for replying. I wanted the double <br>s because after my content, I wanted the "hide" to be well seen

i.e.

end of content, blah blah!

<< hide
Back to top
View user's profile Send private message
waterlilies



Joined: 21 Apr 2003
Posts: 3

PostPosted: Sat May 31, 2003 6:59 pm    Post subject: Reply with quote

Okay, I understand what you're trying to do. So did you figure out what the problem is then? If not, I think if you put two <br> tags before "hide," you should also do that before "more." Perhaps that's why you have two <br>'s after you've clicked on "more."
Back to top
View user's profile Send private message Visit poster's website
epolady



Joined: 30 Jul 2002
Posts: 800
Location: Texas

PostPosted: Sun Jun 01, 2003 8:09 am    Post subject: Reply with quote

Mm, okay, I'll have to test it out and see. Thanks! Smile
Back to top
View user's profile Send private message
Tanman



Joined: 28 Nov 2002
Posts: 36

PostPosted: Sun Jun 29, 2003 4:22 am    Post subject: Reply with quote

Hi.

This particular mod looks interesting, but when I copied the new code into the get content function, and place the code
Code:

function get_the_content($more_link_text='(more...)', $stripteaser=0, $more_file='') {
   global $id,$postdata,$more,$c,$withcomments,$page,$pages,$multipage,$numpages;
   global $HTTP_SERVER_VARS, $preview;
   global $querystring_start, $querystring_equal, $querystring_separator;
   //$output = '';
   $output .= '<span id="varP'.$id.'"><br /><a href="'.$file.'#'.$id.'" onclick="showMore('.$id.',\''.$file.'#'.$id.'\'); return false">read more »</a></span><div id="varXYZ'.$id.'" style="display: none">'.$content[1].'<br /><a href="#'.$id.'" onclick="showMore('.$id.',0); return true">« hide more</a></div>';


Then on ever post, it just has a link "Read More" I am a bit baffled what it is and what I can do about it to work properly.

Any help appreciated.
Back to top
View user's profile Send private message
Eyevan



Joined: 16 Aug 2002
Posts: 18

PostPosted: Sun Jun 29, 2003 6:09 pm    Post subject: Reply with quote

I tried installing this hack, and there was a tiny error, which I can't seem to fix... I'm not sure what to do, but I'll tell you what I did...

I followed every instruction except I replaced this code:
Code:
$output .= '<a name="more'.$id.'"></a>'.$content[1];


with dodo's replacement (except I customized the text (which i put here in CAPITALS):
Code:
$output .= " <span id=\"varP$id\"><br /><a href=\"$file#$id\" onclick=\"showMore($id,'$file#$id');return false;\">More »</a></span><div id=\"varXYZ$id\" style=\"display: none\">$content[1]<br /><a href=\"#$id\" onclick=\"showMore($id,0);return true;\">« Less</a></div>";


Following that I uploaded the file and placed the javascript code in my header in my index page. Well, the problem is, the <b>(more...)</b> text link still shows up instead of <b>More »</b> first!! I want to "delete" (more...), so that only <b>More »</b> would show up in replacement.

However, in my blog, you have to click b2's default (More...) link to get to the More » link, which then opens up when you click it. So, how do I fix this error?
_________________
Blog + Meme
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group