View previous topic :: View next topic |
Author |
Message |
dodo
Joined: 25 Jan 2002 Posts: 35
|
Posted: Wed Apr 16, 2003 12:44 am Post subject: read more javascript hack |
|
|
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 |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Wed Apr 16, 2003 2:40 am Post subject: |
|
|
nice hack dodo =D thanks _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
mcgub
Joined: 19 Apr 2003 Posts: 27
|
Posted: Sat Apr 19, 2003 6:18 pm Post subject: |
|
|
That is sweet...nice work.  _________________ 7 out of 10 voices in my head say I'm not crazy |
|
Back to top |
|
 |
bigsimon
Joined: 04 Jan 2003 Posts: 13
|
Posted: Sat Apr 19, 2003 6:40 pm Post subject: |
|
|
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 |
|
 |
mcgub
Joined: 19 Apr 2003 Posts: 27
|
Posted: Sat Apr 19, 2003 7:04 pm Post subject: |
|
|
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 |
|
 |
Cyberian75
Joined: 26 Sep 2002 Posts: 1283 Location: Oregon
|
Posted: Sat Apr 19, 2003 8:49 pm Post subject: |
|
|
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 |
|
 |
waterlilies
Joined: 21 Apr 2003 Posts: 3
|
Posted: Mon Apr 21, 2003 2:17 am Post subject: |
|
|
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 |
|
 |
Candle
Joined: 23 Dec 2002 Posts: 547
|
Posted: Mon Apr 21, 2003 5:31 pm Post subject: nice hack |
|
|
wish they would have hacks like this for pmachine and easy like this to install . _________________ My Game Forum
 |
|
Back to top |
|
 |
epolady
Joined: 30 Jul 2002 Posts: 800 Location: Texas
|
Posted: Wed May 28, 2003 9:23 am Post subject: |
|
|
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 |
|
 |
waterlilies
Joined: 21 Apr 2003 Posts: 3
|
Posted: Wed May 28, 2003 10:11 pm Post subject: |
|
|
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 |
|
 |
epolady
Joined: 30 Jul 2002 Posts: 800 Location: Texas
|
Posted: Thu May 29, 2003 2:34 am Post subject: |
|
|
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 |
|
 |
waterlilies
Joined: 21 Apr 2003 Posts: 3
|
Posted: Sat May 31, 2003 6:59 pm Post subject: |
|
|
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 |
|
 |
epolady
Joined: 30 Jul 2002 Posts: 800 Location: Texas
|
Posted: Sun Jun 01, 2003 8:09 am Post subject: |
|
|
Mm, okay, I'll have to test it out and see. Thanks!  |
|
Back to top |
|
 |
Tanman
Joined: 28 Nov 2002 Posts: 36
|
Posted: Sun Jun 29, 2003 4:22 am Post subject: |
|
|
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 |
|
 |
Eyevan
Joined: 16 Aug 2002 Posts: 18
|
Posted: Sun Jun 29, 2003 6:09 pm Post subject: |
|
|
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 |
|
 |
|