View previous topic :: View next topic |
Author |
Message |
dodo
Joined: 25 Jan 2002 Posts: 35
|
Posted: Tue Jun 10, 2003 9:50 pm Post subject: multi-more javascript hack (addition to my other hack) |
|
|
first make sure you read this and then
UPDATED THE CODE ON AUGUST 24, 2003
in the original hack code for b2template.functions.php
find the following
Code: |
if (count($content)>1) {
if ($more) {
$output .= $content[1];
} else {
$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>";
}
}
|
and replace it with
Code: |
if(count($content) == 2) {
if ($more) {
$output .= $content[1];
} else {
if(strstr($content[1], "<!--endmore-->")) {
$tail = explode("<!--endmore-->", $content[1]);
$output .= " <span id=\"varP$id\"><br /><a href=\"$file#$id\" onclick=\"showMore($id,'$file#$id');return false;\" target=\"_self\">read more »</a></span><div id=\"varXYZ$id\" style=\"display: none\">$tail[0]<a href=\"#$id\" onclick=\"showMore($id,0);return true;\" target=\"_self\">« hide more</a></div>";
$output .= $tail[1];
} else {
$output .= " <span id=\"varP$id\"><br /><a href=\"$file#$id\" onclick=\"showMore($id,'$file#$id');return false;\" target=\"_self\">read more »</a></span><div id=\"varXYZ$id\" style=\"display: none\">$content[1]<br /><a href=\"#$id\" onclick=\"showMore($id,0);return true;\" target=\"_self\">« hide more</a></div>";
}
}
}
elseif (count($content)>2) {
$k = $id;
for($i = 1; $i <= count($content); $i++) {
$k = $k + 10000000;
if(strstr($content[$i], "<!--endmore-->")) {
$tail = explode("<!--endmore-->", $content[$i]);
$output .= "<span id=\"varP$k\"><br /><a href=\"$file#$k\" onclick=\"showMore($k,'$file#$k');return false;\" target=\"_self\">read more »</a></span><div id=\"varXYZ$k\" style=\"display: none\">$tail[0]<br /><a href=\"#$id\" onclick=\"showMore($k,0);return true;\" target=\"_self\">« hide more</a></div>";
$output .= $tail[1];
} else {
$output .= $content[$i];
}
}
}
|
to post more than one more items, use <!--more--> to begin a more section and use <!--endmore--> to end a more section.
demo here
tweak it if you want. and also, i found a bug in the javascript. change "block" in there to "inline" in the javascript file.
UPDATED THE CODE ON AUGUST 24, 2003 _________________ http://pure-essence.net
b2 rocks
Last edited by dodo on Mon Aug 25, 2003 4:35 pm; edited 7 times in total |
|
Back to top |
|
 |
epolady
Joined: 30 Jul 2002 Posts: 800 Location: Texas
|
Posted: Wed Jun 11, 2003 2:12 am Post subject: |
|
|
Looks great! I'll have to try it out tonight. |
|
Back to top |
|
 |
xytx
Joined: 24 May 2003 Posts: 48
|
Posted: Wed Jun 11, 2003 5:36 am Post subject: |
|
|
this is a great hack.. ! |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Wed Jun 11, 2003 6:24 am Post subject: |
|
|
i like this one.
Hmm maybe can make something like <!--more-->Click Here To Read About This<!--endmore-->
Click Here To Read About This will be a link, thus everypost readmore link will be unique _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
dodo
Joined: 25 Jan 2002 Posts: 35
|
|
Back to top |
|
 |
phona
Joined: 07 Feb 2002 Posts: 35 Location: Australia
|
Posted: Wed Jun 11, 2003 8:58 am Post subject: |
|
|
is there a way tomay it work witht eh endmore if there's only one "more" section?
(does that even make sense?) _________________ Just a sweet lil Aussie chick (yeah, whatever) |
|
Back to top |
|
 |
Lelerz
Joined: 09 Apr 2002 Posts: 7 Location: NY
|
Posted: Wed Jun 11, 2003 9:01 am Post subject: |
|
|
phona wrote: | is there a way tomay it work witht eh endmore if there's only one "more" section?
(does that even make sense?) |
Yeah, I noticed this too... like say, I wanted:
Code: |
Hi this is my entry! Want to see a pic of my cat?
<!--more-->
Pic here
<!--endmore-->
Isn't she so adorable? Blah blah blah.
|
Currently, the hack doesn't do that. It just makes everything behind that sole MORE hidden. |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Wed Jun 11, 2003 7:04 pm Post subject: |
|
|
That is not exactly waht i mean.
http://csnation.counter-strike.net/ u see the "read more link" is always diff text. Lik [ see press release text (266 more words) ] [ more screenshots/full 6.09 changelog (644 more words) ] etc =D _________________
++ GamerZ.Per.Sg - Complex Simplicity |
|
Back to top |
|
 |
dodo
Joined: 25 Jan 2002 Posts: 35
|
Posted: Wed Jun 11, 2003 9:55 pm Post subject: |
|
|
there's a bug in the code. make sure you change it
please add ABOVE
Code: | for($i = 1; $i <= count($content); $i++) { |
this
_________________ http://pure-essence.net
b2 rocks |
|
Back to top |
|
 |
dodo
Joined: 25 Jan 2002 Posts: 35
|
Posted: Thu Jun 19, 2003 3:32 pm Post subject: another bug fix |
|
|
scratch this, i updated the code in the first post. _________________ http://pure-essence.net
b2 rocks
Last edited by dodo on Mon Aug 25, 2003 1:24 am; edited 1 time in total |
|
Back to top |
|
 |
niten
Joined: 03 Jun 2003 Posts: 6
|
Posted: Mon Jun 23, 2003 4:31 pm Post subject: |
|
|
If I use multiple more's in one post, clicking on the second/third/whatever more links just open up the first more section. |
|
Back to top |
|
 |
Tanman
Joined: 28 Nov 2002 Posts: 36
|
Posted: Fri Jul 04, 2003 4:26 am Post subject: |
|
|
just a query, when i add the error, it says that there is an undefined function (to that effect) to b2vars.php.
Any ideas about that? TIA.
Wei-Yen |
|
Back to top |
|
 |
XYboi
Joined: 17 Feb 2003 Posts: 18 Location: Miami, FL.
|
Posted: Thu Aug 21, 2003 5:47 pm Post subject: |
|
|
I was wondering if anyone had gottent the second and third <!--more--> codes to work, I seem to be having issues opening any of the one's after the first. I just opens up the first one again. Anyone kno what I'm doing wrong? Thanks.
-http://www.xyboi.org.... u can see it on the latest entry. _________________ --
* Support the Site. Support the Boi. Visit XYboi.S-S.Org * |
|
Back to top |
|
 |
kristal
Joined: 27 Jun 2002 Posts: 17
|
Posted: Mon Aug 25, 2003 12:20 am Post subject: |
|
|
I'm having the same problem with all extra "read more"s opening up the first one again. anyone have a fix? |
|
Back to top |
|
 |
dodo
Joined: 25 Jan 2002 Posts: 35
|
Posted: Mon Aug 25, 2003 1:26 am Post subject: |
|
|
for those who have problem, try use the new updated code in the very first post. _________________ http://pure-essence.net
b2 rocks |
|
Back to top |
|
 |
|