[2.0.6] Anchor BBCode

The cleanup is complete. This forum is now read only.

Rating:

Excellent!
4
44%
Very Good
2
22%
Good
1
11%
Fair
0
No votes
Poor
2
22%
 
Total votes: 9

asavage
Registered User
Posts: 39
Joined: Sun Dec 04, 2005 8:50 pm
Location: Duvall, Wash.
Name: Al Savage
Contact:

Post by asavage »

The problem with Firefox et al not working is that this MOD was writing an invalid NAME attribute. It was prepending the NAME attribute with a '#' char, as in:

Code: Select all

<a name="#55_anchor_1">
where "55" is the post number and "1" is the anchor number within that post.

The '#' is not (may not be?) a valid char for the start of an anchorname. Heck, it might not be allowed anywhere within an anchorname; I didn't check.

I repaired this MOD problem (prepending the anchorname with '#') by changing this line

Code: Select all

   $bbcode_tpl['anchor'] = str_replace('{URL}', '#%s_\\1', $bbcode_tpl['anchor']);
by removing the '#':

Code: Select all

   $bbcode_tpl['anchor'] = str_replace('{URL}', '%s_\\1', $bbcode_tpl['anchor']);
Building upon mac-rolec's fix for Multi BBCode 1.4.0, I removed the offending '#' and it seems to work OK now with Mozilla/Firefox. Installed OK via EM 0.3.0 .

Code: Select all

############################################################## 
## MOD Title: Anchor BBCode 
## MOD Author: Xore < [email protected] > (Robert Hetzler) http://www.xore.ca 
## MOD Description: Anchors for hyperlinking within posts 
## MOD Version: 1.0.1 
## 
## Installation Level: (Easy) 
## Installation Time: 3 Minutes 
## Files To Edit: posting.php,
##                privmsg.php,
##                includes/bbcode.php,
##                templates/subSilver/bbcode.tpl,
##                templates/subSilver/posting_body.tpl,
##                language/lang_english/lang_main.php,
##                language/lang_english/lang_bbcode.php
## Included Files: (n/a) 
############################################################## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
############################################################## 
## Author Notes: hyperlink within posts! FAQs! YAY!
############################################################## 
## MOD History: 
## 
##   2003-10-27 - Version 1.0.1 
##      - Updated to reflect the *actual* location of the multiple bbcode mod
## 
##   2003-09-26 - Version 1.0.0 
##      - Inspired by a need for coherent faqs, and enhanced by ideas
##        on the original thread devoted to this type of BBCode.
## 
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
#
# IMPORTANT: you MUST first install the latest version of the Multi Quick BBCode Mod (1.2.1+).
# This can be found here: http://www.phpbb.com/phpBB/viewtopic.php?t=145513
# 

#
#-----[ OPEN ]------------------------------------------
#
posting.php

#
#-----[ FIND ]------------------------------------------
#
'L_EMPTY_MESSAGE' => $lang['Empty_message'],

#
#-----[ BEFORE, ADD ]------------------------------------------
#

   'L_BBCODE_2_HELP' => $lang['bbcode_2_help'],
   'L_BBCODE_3_HELP' => $lang['bbcode_3_help'],
   'L_BBCODE_4_HELP' => $lang['bbcode_4_help'],

#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php

#
#-----[ FIND ]---------------------------------
#
$EMBB_widths = array(''
$EMBB_values = array(''

#
#-----[ IN-LINE FIND ]---------------------------------
#
$EMBB_widths = array(''


#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'60','40','80'


#
#-----[ IN-LINE FIND ]---------------------------------
#
$EMBB_values = array(''


#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'Anchor','Goto','Gotopost'

#
#-----[ FIND ]------------------------------------------
#
$bbcode_tpl['code_open'] = str_replace('{L_CODE}', $lang['Code'], $bbcode_tpl['code_open']);

#
#-----[ AFTER, ADD ]------------------------------------------
#

   $bbcode_tpl['anchor'] = str_replace('{URL}', '%s_\\1', $bbcode_tpl['anchor']);

   $bbcode_tpl['goto_open_1'] = str_replace('{URL}', '#\\1', $bbcode_tpl['goto_open']);
   $bbcode_tpl['goto_open_2'] = str_replace('{URL}', '#%s_\\1', $bbcode_tpl['goto_open']);
   $bbcode_tpl['goto_open_3'] = str_replace('{URL}', '#\\1_\\2', $bbcode_tpl['goto_open']);

   global $phpEx;
   $bbcode_tpl['gotopost_open_1'] = str_replace('{URL}', append_sid("viewtopic.$phpEx?p=" . '\\1') . '#\\1', $bbcode_tpl['gotopost_open']);
   $bbcode_tpl['gotopost_open_2'] = str_replace('{URL}', append_sid("viewtopic.$phpEx?p=" . '\\1') . '#\\1_\\2', $bbcode_tpl['gotopost_open']);

#
#-----[ FIND ]------------------------------------------
#
$text = str_replace("[/size:$uid]", $bbcode_tpl['size_close'], $text);

#
#-----[ AFTER, ADD ]------------------------------------------
#

   $post_id = ( isset($GLOBALS['postrow'][$GLOBALS['i']]['post_id']) ) ? $GLOBALS['postrow'][$GLOBALS['i']]['post_id'] : ( ( isset($GLOBALS['post_id']) ) ? $GLOBALS['post_id'] : 0 );

   // anchor
   $text = preg_replace("/\[anchor:$uid\]([a-zA-Z]\w*?)\[\/anchor:$uid\]/si", sprintf($bbcode_tpl['anchor'],$post_id), $text);

   // goto
   $text = preg_replace("/\[goto=([\d]+?):$uid\]/si", $bbcode_tpl['goto_open_1'], $text);
   $text = preg_replace("/\[goto=([a-zA-Z]\w*?):$uid\]/si", sprintf($bbcode_tpl['goto_open_2'],$post_id), $text);
   $text = preg_replace("/\[goto=([\d]+?),([a-zA-Z]\w*?):$uid\]/si", $bbcode_tpl['goto_open_3'], $text);
   $text = str_replace("[/goto:$uid]", $bbcode_tpl['goto_close'], $text);

   // goto post
   $text = preg_replace("/\[gotopost=([\d]+?):$uid\]/si", $bbcode_tpl['gotopost_open_1'], $text);
   $text = preg_replace("/\[gotopost=([\d]+?),([a-zA-Z]\w*?):$uid\]/si", $bbcode_tpl['gotopost_open_2'], $text);
   $text = str_replace("[/gotopost:$uid]", $bbcode_tpl['gotopost_close'], $text);

#
#-----[ FIND ]------------------------------------------
#
$text = preg_replace("#\[size=([1-2]?[0-9])\](.*?)\[/size\]#si", "[size=\\1:$uid]\\2[/size:$uid]", $text);

#
#-----[ AFTER, ADD ]------------------------------------------
#

   // [goto] and [gotopost] and [anchor]
   $text = preg_replace("#\[anchor\]([a-zA-Z]\w*?)\[/anchor\]#si", "[anchor:$uid]\\1[/anchor:$uid]", $text);

   $text = preg_replace("#\[goto=([\d]+?)\](.*?)\[/goto\]#si", "[goto=\\1:$uid]\\2[/goto:$uid]", $text);
   $text = preg_replace("#\[goto=([a-zA-Z]\w*?)\](.*?)\[/goto\]#si", "[goto=\\1:$uid]\\2[/goto:$uid]", $text);
   $text = preg_replace("#\[goto=([\d]+?),([a-zA-Z]\w*?)\](.*?)\[/goto\]#si", "[goto=\\1,\\2:$uid]\\3[/goto:$uid]", $text);

   $text = preg_replace("#\[gotopost=([\d]+?)\](.*?)\[/gotopost\]#si", "[gotopost=\\1:$uid]\\2[/gotopost:$uid]", $text);
   $text = preg_replace("#\[gotopost=([\d]+?),([a-zA-Z]\w*?)\](.*?)\[/gotopost\]#si", "[gotopost=\\1,\\2:$uid]\\3[/gotopost:$uid]", $text);

#
#-----[ OPEN ]------------------------------------------
# You need to do this for all of your installed template styles
#
templates/subSilver/bbcode.tpl

#
#-----[ FIND ]------------------------------------------
#
<!-- BEGIN size_close --></span><!-- END size_close -->

#
#-----[ AFTER, ADD ]------------------------------------------
#

<!-- BEGIN anchor --><a name="{URL}"></a><!-- END anchor -->

<!-- BEGIN goto_open --><a href="{URL}"><!-- END goto_open -->
<!-- BEGIN goto_close --></a><!-- END goto_close -->

<!-- BEGIN gotopost_open --><a href="{URL}"><!-- END gotopost_open -->
<!-- BEGIN gotopost_close --></a><!-- END gotopost_close -->

#
#-----[ OPEN ]------------------------------------------
# You need to do this for all of your installed template styles
#
templates/subSilver/posting_body.tpl

#
#-----[ FIND ]------------------------------------------
#
f_help = "{L_BBCODE_F_HELP}";

#
#-----[ AFTER, ADD ]------------------------------------------
#

n2_help = "{L_BBCODE_2_HELP}";
n3_help = "{L_BBCODE_3_HELP}";
n4_help = "{L_BBCODE_4_HELP}";

#
#-----[ FIND ]---------------------------------
#
# NOTE: the actual line to find is MUCH longer, containing all the bbcode tags
#
bbtags = new Array(

#
#-----[ IN-LINE FIND ]---------------------------------
#
'[url]','[/url]'

#
#-----[ IN-LINE AFTER, ADD ]---------------------------------
#
,'[anchor]','[/anchor]','[goto=]','[/goto]','[gotopost=]','[/gotopost]'


#
#-----[ OPEN ]------------------------------------------
# You need to do this for all installed languages
#
language/lang_english/lang_main.php

#
#-----[ FIND ]------------------------------------------
# Full line in English is: $lang['bbcode_f_help'] = 'Font size: [size=x-small]small text[/size]';
#
$lang['bbcode_f_help'] =

#
#-----[ AFTER, ADD ]------------------------------------------
# You need to do this for all installed languages
#
$lang['bbcode_2_help'] = 'Anchor: [anchor]name[/anchor]';
$lang['bbcode_3_help'] = 'Goto: [goto=name]text[/goto] [goto=post]text[/goto] [goto=post,name]text[/goto]';
$lang['bbcode_4_help'] = 'Gotopost: [gotopost=post]text[/goto] [gotopost=post,name]text[/goto]';

#
#-----[ OPEN ]------------------------------------------
# You need to do this for all installed languages
#
language/lang_english/lang_bbcode.php

#-----[ FIND ]------------------------------------------
# Full line in English is too long too be included here
#
$faq[] = array("How to change the text colour or size", "

#
#-----[ AFTER, ADD  ]------------------------------------------
#
// Anchor start
$faq[] = array("How to make anchors and link inside posts","This board has anchoring and linking within posts enabled.<ul><li>To make anchors within your posts, just specify <b>[anchor]</b><i>anchorname</i><b>[/anchor]</b>.</li><li>To link to that anchor:<ol type=\"1\"><li>From within that post, use <b>[goto=<i>anchorname</i>]</b>text<b>[/goto]</b>.</li><li>From another post on the same page, use <b>[goto=<i>postnum</i>,<i>anchorname</i>]</b>text<b>[/goto]</b>.</li><li>From another post on a different page, use <b>[gotopost=<i>postnum</i>,<i>anchorname</i>]</b>text<b>[/gotopost]</b>.</li></ol></li><li>You can also use goto and gotopost to link to the top of any post:<ol type=\"1\"><li> <b>[goto=<i>postnum</i>]</b>text<b>[/goto]</b> if the other post is on the same page,</li><li>Otherwise use <b>[gotopost=<i>postnum</i>]</b>text<b>[/gotopost]</b></li></ol>.</li></ul>");

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM

I have only tested that I can create an anchor via

Code: Select all

{anchor}anchorname_1{/anchor}
and use it as a reference in another post

Code: Select all

This is a {gotopost=55,anchorname_1}link to an anchor in another post{/gotopost}.
and it works correctly.

I frankly do not follow some of the code for the other things implemented, I don't code for a living, YMMV, blah blah

To recap:
* Install EM 0.3.0
* Install Multi BBCode 1.4.0c
* Copy-n-Paste above code to a file ending in .txt or .mod
* Put that file in admin/mods/dirname
* From ACP's MOD Center, run "Install MODs"
Last edited by asavage on Mon Dec 05, 2005 5:21 am, edited 1 time in total.
Regards,
Al S.
User avatar
beggers
Registered User
Posts: 1257
Joined: Fri Nov 23, 2001 8:19 pm
Location: Las Vegas
Contact:

Post by beggers »

Thanks very much for the Firefox fix! I'll give it a shot.
User avatar
raiisak
Registered User
Posts: 36
Joined: Sun Dec 04, 2005 3:23 am

Post by raiisak »

I get this

Code: Select all

Critical Error

FIND FAILED: In file [posting.php] could not find:

$EMBB_keys = array('' 
$EMBB_widths = array('' 
$EMBB_values = array('' 

MOD script line #62 :: FAQ :: Report 
  
I get this on several mods.. It is not a single line called EMBB in posting.php
I meet the recuirements, ver. .18 and the latest easymod and multible BBcode ++

What can I do? I really whant this BBCode =(
By_Korsan
Registered User
Posts: 3
Joined: Mon Oct 17, 2005 6:46 pm
Contact:

FORUM

Post by By_Korsan »

Katılıyorum
User avatar
raiisak
Registered User
Posts: 36
Joined: Sun Dec 04, 2005 3:23 am

Post by raiisak »

LOL!
Is that a bad word from Finland?
asavage
Registered User
Posts: 39
Joined: Sun Dec 04, 2005 8:50 pm
Location: Duvall, Wash.
Name: Al Savage
Contact:

Post by asavage »

[quote="raiisak"]I get this

Code: Select all

Critical Error

FIND FAILED: In file [posting.php] could not find:

$EMBB_keys = array('' 
You are trying to use the downloadable version, which does not work because $EMBB_keys were moved to bbcode.php some time ago. Use the MOD code I posted a few posts upthread instead.
Regards,
Al S.
Francisco.phpBB
Registered User
Posts: 241
Joined: Fri Dec 03, 2004 2:21 pm
Location: ßrazil (UTC -3)

Why I need Goto tag?

Post by Francisco.phpBB »

Hi Xore!

I thank you for this mod.
It is very useful for me.

I have a doubt.
Gotopost tag makes everything what Goto tag makes.
Why I need Goto tag?

Francisco
faqcorner
Registered User
Posts: 51
Joined: Thu Apr 14, 2005 2:18 am

Post by faqcorner »

this mod installed correctly, but doesn't work, just, when I do the anchor tags, it shows up as regular text
faqcorner
Registered User
Posts: 51
Joined: Thu Apr 14, 2005 2:18 am

Post by faqcorner »

faqcorner wrote: this mod installed correctly, but doesn't work, just, when I do the anchor tags, it shows up as regular text


nvm fixed it
User avatar
shadav
Registered User
Posts: 150
Joined: Thu Dec 01, 2005 7:12 pm
Location: Drowning In Corn Fields
Contact:

Post by shadav »

mac-rolec wrote: Even better. I rewrote the mod a little so you can see the changes better and it works with multi bbcode 1.4.0. too (i don't know if this is allowed).

I did not test this with Easymod, I suggest you just do it manually!!

I tested it only on my forum and it works fine.

Don't forget to backup first!
First off thank you for this fix...i was able to install the mod

however there are no buttons for the codes?
acharabia
Registered User
Posts: 139
Joined: Fri Sep 27, 2002 4:41 pm
Location: SEOUL/KOREA
Contact:

Post by acharabia »

I suceed installing this MOD but I don't understand what this MOD maan.
Anyone can tell easily about this MOD? When do we use this MOD?
And new 3 buttons made and there is no "mouse-hover" fonctions
for line explication below on "post-body.tpl" How can I do this mouse-hover?
Refence also install but no fonction mouse-hover either. :cry:
(But fourfuantely, I understand this Ref. bbcode meaning.)

image

I can't see "font color" section(=help bar) when mouse-hover
on "anchor" button.
Image
acharabia
Registered User
Posts: 139
Joined: Fri Sep 27, 2002 4:41 pm
Location: SEOUL/KOREA
Contact:

Post by acharabia »

hmmm... I'm very interesting about this MOD.
Success to install and there are some problems.

1. Understanding to drill:
2. Help bar no show:


----------------------

I got some understanding about this mod such like FAQ system
(=mechanism). e.g. When I click a certain hyperlink, directly
go to pagedown(or pageup) and we can see contents about that
hyperlink, doesn't it? Yeh... I can understanding... Sounds good...
How to make anchors and link inside posts
This board has anchoring and linking within posts enabled.
To make anchors within your posts, just specify .
To link to that anchor:
From within that post, use text.
From another post on the same page, use [goto=postnum,anchorname]text[/goto].
From another post on a different page, use [gotopost=postnum,anchorname]text[/gotopost].
You can also use goto and gotopost to link to the top of any post:
text if the other post is on the same page,
Otherwise use [gotopost=postnum]text[/gotopost]


At first, I can't make .
e.g. we can see top line of this page "hmmm..."
I set anchor there and when click go to "hmmm..."
line doesn't it? and I'd like to set anchor that line
as on my phpBB. But not fonction on my phpBB!!!

[goto] commend? Working!!! funny...
e.g. [gotopost=1] going to the page of
the very first time to post on topic by me on my phpBB.
But problem is nobody know of topic ID!!!
And this MOD can NOT find 2, 3, 4... only 1 find...
Only "[gotopost=1]" is fonction!!! We should set topic ID number
there but who know topic ID? e.g. there are 100 topic on my phpBB...
What is 77 order topic? And that topic is what number of ID?
Nobody know it... :cry:

[gotopost=postnum,anchorname]text[/gotopost].
[gotopost=77,hmmm...]click here and see[/gotopost] (77 mean that topic ID)

If you would like to go 77 topic and directly to "hmmm..." in that page...
so you make code like above. Is that ok? then Imagin I set anchor
to "hmmm..." in same page. (1,2,3,4,5, mean hyperlink on same page.)

[goto=1,hmmm...]click here to see[/gotopost].
under 20 line below...
[goto=2,hmmm...]click here to see[/gotopost].
under 30 line below...
[goto=3,hmmm...]click here to see[/gotopost].
under 40 line below...
[goto=4,hmmm...]click here to see[/gotopost].
under 50 line below...
[goto=5,hmmm...]click here to see[/gotopost].
under 60 line below...

Not fonction in same page... because "anchor" commend
no fonction on view-topic body. Only show nude html code
like this "[anchor]hmmm...[/anchor]"
This is very serious
problem on this MOD. Top important fonction of "anchor"
no work... on the page...

Did anybody understand what I say?
It's very diffecult to explain and someone who
understand and fonction very well this "anchor"
MOD help-me... plz. I like and insterest about
this MOD but not very clearly about how to drill
to this MOD. I'm very interesting this MOD with
Footnote. Just click the footnote number and see
below those contents... Is is possible? if possible
show me a code. plz.

Now I know why vote "poor" is
much on this MOD qualilty~ hehe~ :P
(MOD aim is very good but not clearly fonction...)
Image
User avatar
julesagogo
Registered User
Posts: 74
Joined: Fri Oct 01, 2004 3:10 pm
Location: Richmond, VA

Post by julesagogo »

Does anyone have this working on a forum? I'd like to see how it works before I install it.

I'm looking for something that gives all users/viewers a link to the post inside each post so they can reference it later (regardless of ownership of the post).

It might look like this:

Code: Select all

<a href="http://forum/domain.com/viewtopic.php?p=9638#9638">Linkback</a>


or "This post's link location" or whatever.

Thanks in advance!
asavage
Registered User
Posts: 39
Joined: Sun Dec 04, 2005 8:50 pm
Location: Duvall, Wash.
Name: Al Savage
Contact:

Post by asavage »

I use this MOD, and I use anchors extensively in a couple of long posts. Here's an example. In this page, the Table of Contents (TOC) items all link to anchors placed in the same post's text.

http://nissandiesel.dyndns.org/viewtopic.php?p=4#4

Click on any item in the TOC, and you're taken downpage to that section.

Using the same anchors, to link to a specific section from outside the forum:

http://nissandiesel.dyndns.org/viewtopi ... kemanifold

and, to refer to that same section within a post:

Code: Select all

[gotopost=4,intakemanifold]Intake Manifold Grunge[/gotopost]
Regards,
Al S.
asavage
Registered User
Posts: 39
Joined: Sun Dec 04, 2005 8:50 pm
Location: Duvall, Wash.
Name: Al Savage
Contact:

Post by asavage »

julesagogo wrote: I'm looking for something that gives all users/viewers a link to the post inside each post [thread] so they can reference it later (regardless of ownership of the post).

You want the current post's URL, expressed in a link in a user's post that's generated automatically. That's not what this MOD does.

I refer to specific posts often, but I do it manually.
  • Obtain the PostIDnum of the post by hovering the mouse pointer over the "Quote" button at the top of the post, and reading it from the end of the URL in the status bar at the bottom of the browser.
    • Edit the URL in the browser's Address field, removing everything after the '?' and replacing it with "p=PostIDnum#PostIDnum"
    • Or, if the MOD is installed, use PostIDnum in a [gotopost] tag.
Example (jumps to a post in the middle of a thread):
http://nissandiesel.dyndns.org/viewtopic.php?p=3318#3318

I don't know of a tool or MOD to automatically do that. But I've gotten good at doing it manually ;)

What this MOD does is twofold: allows one to use the [gotopost=PostIDnum] BBcode tag to shortcut having the entire FQDM inserted, and it also allows one to define and link to user-defined points within a post, via the [anchor] tag (in that case, [gotopost=PostIDnum,anchorname].
Regards,
Al S.
Post Reply

Return to “[2.0.x] MOD Database Cleanup”