Interne Links im gleichen Fenster

Probleme bei der regulären Arbeiten mit phpBB, Fragen zu Vorgehensweisen oder Funktionsweise sowie sonstige Fragen zu phpBB im Allgemeinen.
Forumsregeln
phpBB 2.0 hat das Ende seiner Lebenszeit überschritten
phpBB 2.0 wird nicht mehr aktiv unterstützt. Insbesondere werden - auch bei Sicherheitslücken - keine Patches mehr bereitgestellt. Der Einsatz von phpBB 2.0 erfolgt daher auf eigene Gefahr. Wir empfehlen einen Umstieg auf phpBB 3.1, welches aktiv weiterentwickelt wird und für welches regelmäßig Updates zur Verfügung gestellt werden.
BZebra
Mitglied
Beiträge: 576
Registriert: 17.12.2002 22:45
Kontaktdaten:

Beitrag von BZebra »

Ah, ich habs so gut wie.

Also, erst mal die original Anleitung zum relative link MOD:

Code: Alles auswählen

###############################################
##	Hack Title:		Relative links
##	Hack Version:	1.0.0
##	Author:			Freakin' Booty ;-P
##	Website:		http://freakingbooty.no-ip.com
##	Description:	Adds the functionality to point to links relative to the forum's root
##					directory. Moving a forum to another server will automatically update the
##					relative links once the variables in the board configuration have been
##					updated.
##	Compatibility:	2.0.0 - 2.0.10
##	Usage:
##		[url]rel://viewtopic.php?t=1[/url]
##		[url=rel://viewforum.php?f=1]description[/url]
##
##	Installation Level: Easy
##	Installation Time: 2 - 3 minutes
##
##	Files To Edit: 1
##		includes/bbcode.php
##
##	Included Files: 0
##
##	History:
##		1.0.0	Initial release
##
##	Author Notes:
##		From now on, I will be supplying patch files as much as possible. If you don't know
##		what these are, either Google it or just leave them alone.
##
##	Support:		http://www.phpbbhacks.com/forums
##	Copyright:		©2004 Freakin' Booty ;-P - Relative links 1.0.0
##
###############################################
##   You downloaded this hack from phpBBHacks.com, the #1 source for phpBB related downloads.
##   Please visit http://www.phpbbhacks.com/forums for support.
###############################################
##
###############################################
##	This hack is released under the GPL License.
##	This hack can be freely used, but not distributed, without permission.
##	Intellectual Property is retained by the hack author(s) listed above.
###############################################

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

#
#-----[ FIND ]--------------------------------------------
#
	$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
	$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);

#
#-----[ AFTER, ADD ]--------------------------------------
#
	$bbcode_tpl['url5'] = str_replace('{URL}', bbcode_relative_links() . '\\2', $bbcode_tpl['url']);
	$bbcode_tpl['url5'] = str_replace('{DESCRIPTION}', bbcode_relative_links() . '\\2', $bbcode_tpl['url5']);

	$bbcode_tpl['url6'] = str_replace('{URL}', bbcode_relative_links() . '\\2', $bbcode_tpl['url']);
	$bbcode_tpl['url6'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url6']);

#
#-----[ FIND ]--------------------------------------------
#
	// matches a [url]xxxx://www.phpbb.com[/url] code..
	$patterns[] = "#\[url\]([\w]+?://[^ \"\n\r\t<]*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url1'];

#
#-----[ BEFORE, ADD ]-------------------------------------
#
	// matches a [url]rel://viewtopic.php[/url] code..
	$patterns[] = "#\[url\](rel://[\./]*([^ \"\n\r\t<]*?))\[/url\]#is";
	$replacements[] = $bbcode_tpl['url5'];

#
#-----[ FIND ]--------------------------------------------
#
	// [url=xxxx://www.phpbb.com]phpBB[/url] code..
	$patterns[] = "#\[url=([\w]+?://[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url3'];

#
#-----[ BEFORE, ADD ]-------------------------------------
#
	// matches a [url=rel://viewtopic.php]view topic[/url] code..
	$patterns[] = "#\[url\=(rel://[\./]*([^ \"\n\r\t<]*?))\](.*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url6'];

#
#-----[ FIND ]--------------------------------------------
#
?>

#
#-----[ BEFORE, ADD ]-------------------------------------
#
function bbcode_relative_links()
{
	global $board_config;

	$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
	$script_name = ($script_name != '') ? $script_name . '/' : '/';
	$server_name = trim($board_config['server_name']) . '/';
	$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
	$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';

	return $server_protocol . $server_name . $script_name;
}

#
#-----[ SAVE & CLOSE ALL FILES ]--------------------------
#
Die Abgewandelte Form müsste so aussehen:
#
#-----[ OPEN ]--------------------------------------------
#
includes/bbcode.php

#
#-----[ FIND ]--------------------------------------------
#
$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);

#
#-----[ AFTER, ADD ]--------------------------------------
#
$bbcode_tpl['url5'] = str_replace('{URL}', '\\1', $bbcode_tpl['rel']);
$bbcode_tpl['url5'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url5']);

$bbcode_tpl['url6'] = str_replace('{URL}', '\\1', $bbcode_tpl['rel']);
$bbcode_tpl['url6'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url6']);

#
#-----[ FIND ]--------------------------------------------
#
// matches a [url]xxxx://www.phpbb.com[/url] code..
$patterns[] = "#\[url\]([\w]+?://[^ \"\n\r\t<]*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url1'];

#
#-----[ BEFORE, ADD ]-------------------------------------
#
// matches a [url]rel://viewtopic.php[/url] code..
$patterns[] = "#\[url\](forum_root_path[\./]*([^ \"\n\r\t<]*?))\[/url\]#is";
$replacements[] = $bbcode_tpl['url5'];

#
#-----[ FIND ]--------------------------------------------
#
// [url=xxxx://www.phpbb.com]phpBB[/url] code..
$patterns[] = "#\+?://[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url3'];

#
#-----[ BEFORE, ADD ]-------------------------------------
#
// matches a [url=rel://viewtopic.php]view topic
code..
$patterns[] = "#\[url\=(forum_root_path[\./]*([^ \"\n\r\t<]*?))\](.*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url6'];

#
#-----[ FIND ]--------------------------------------------
#

// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;

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

// matches a "forum_root_path/xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 1 dot. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[\n ])((forum_root_path)[^ \"\t\n\r<]*)#is", "\\1<a href=\"\\2\" target=\"_self\">\\2</a>", $ret);

#
#-----[ OPEN ]--------------------------------------------
#
templates/subSilver/bbcode.tpl

#
#-----[ FIND ]--------------------------------------------
#

<!-- BEGIN url --><a href="{URL}" target="_blank" class="postlink">{DESCRIPTION}</a><!-- END url -->

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

<!-- BEGIN rel --><a href="{URL}" target="_self" class="postlink">{DESCRIPTION}</a><!-- END rel -->

#
#-----[ SAVE & CLOSE ALL FILES ]--------------------------
#
Für forum_root_path brauch ich jetzt noch die Variable. $phpbb_root_path vielleicht? Aber keine Ahnung wie man die einbaut.

Ich hab den Anfangsteil der URL bei mir jetzt mal im Klartext eingetragen, da funktioniert es für die Versionen:

Code: Alles auswählen

http://meinedomain.tld/forum/viewtopic.php?irgdenwas
[url]http://meinedomain.tld/forum/viewtopic.php?irgdenwas[/url]
[url=http://meinedomain.tld/forum/viewtopic.php?irgdenwas]Beitrag[/url]
BZebra
Mitglied
Beiträge: 576
Registriert: 17.12.2002 22:45
Kontaktdaten:

Beitrag von BZebra »

BZebra hat geschrieben:Für forum_root_path brauch ich jetzt noch die Variable. $phpbb_root_path vielleicht? Aber keine Ahnung wie man die einbaut.
Wollte noch mal fragen, ob und wie man an die drei blau markierten stellen den forum_root_path automatisch einsetzen lassen kann.
Dann könnte man nämlich daraus mal nen MOD machen. Den root_path dort direkt einzutragen wäre ein bißchen blöd und schon garnicht EM-kompatibel. Außerdem könnte evt. mal jemand drüber schauen, ob der Code so korrekt ist.
Benutzeravatar
Nico Haase
Mitglied
Beiträge: 1100
Registriert: 10.08.2003 15:19
Wohnort: Neu-Anspach / Darmstadt
Kontaktdaten:

Beitrag von Nico Haase »

naja, wenn du eine variable mit dem wert hast, setzt du die einfach ein ;) problem wird nur sein: wo kriegemer die variable her? war da nich eine in $board_config[]? moooooment mal.... die array-elemente script-host und script-path sollten es sein, siehe http://www.phpbb.de/doku/doku2.php?mode=config#config
Buchtips.net bietet mehr als 2500 Buchrezensionen
Antworten

Zurück zu „phpBB 2.0: Administration, Benutzung und Betrieb“