Avatar

Installation de Mon Petit Forum (Design/Themes)

by Auge ⌂, Monday, October 19, 2020, 08:07 (1279 days ago) @ ChristianForum

Hello

Mon Petit Forum est sur cette page.

Traduction :

Hello, I have installed My Small Forum …

It's My Little Forum because that's a proper noun (translator tells me it's "nom propre" in french language). ;-)

… in a page of my site so that it has the same design as the other pages. For this, I created a home.php page in which I call index.php in an iframe. It works great! There is a problem when a page of a site is referred to in a message. I would like this page to open in another tab and not in iframe ... How to do?

You can modify the source code of the functions that creates the links from the BBCodes in the messages. There are two relevant functions (make_link and do_bbcode_url). The line numbers in the following descriptions refers to version 2.4.24.

In make_link you have to change line 318 from …

  $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "$1<a href=\"http://$2\">$2</a>", $string);

… to

  $string = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "$1<a href=\"http://$2\" target=\"_blank\">$2</a>", $string);

In the function do_bbcode_url you have to change the line 438 from …

    if(!isset ($attributes['default'])) return '<a href="'.htmlspecialchars($content).'">'.htmlspecialchars(shorten_url($content)).'</a>';

… to

    if(!isset ($attributes['default'])) return '<a href="'.htmlspecialchars($content).'" target="_blank">'.htmlspecialchars(shorten_url($content)).'</a>';

and line 440

    return '<a href="'.htmlspecialchars ($attributes['default']).'">'.$content.'</a>';

to

    return '<a href="'.htmlspecialchars ($attributes['default']).'" target="_blank">'.$content.'</a>';

The change is to add the attribute "target" with the value "_blank" (with leading underscore) to the link elements. With that every link in an entry should open in a new browser window or in a new tab.

Attention: In the first case (line 318) you have to add a backslash in front of every of the two quotes ('"' to '\"'). In the other two places (lines 438 and 440) don't add backslashes because there this would be wrong.

As last but not least you have to change the first code-line in the file themes/default/main.tpl. Change the HTML-doctype at the end of line 1 of the file from …

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

… to

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

This quick fix will have a disadvantage because of the iframe that surrounds the forum page. You can not predict a uniform behaviour under every single browser configuration. The link will open in a new browser window in one browser, in a new tab of the same browser window in another browser (normal behaviour in most browsers nowadays) and in the same tab (unloading the forum and its surrounding iframe) in a third browser (that would be the dirtiest behaviour).

This is not very desirable.

The clean solution would be to go a second step, altering the forum theme to free the forum from the iframe (this is the element that makes the behaviour of the browsers so unpredictable with the quick fix). Therefore make a copy of the default theme, add the needed changes and copy the result into a new folder inside the directory "themes" (beside "default")). Then you can set this theme as the standard theme of the forum (in the forum settings) and then remove the default theme from the server.

In your case you (or someone else trustwothy) "only" have to alter the main.tpl to add your page menu, and your scripts and alter the stylesheets to adjust colours and dimensions. You can test your changes when you load your changed theme up to the server and set it as your theme in your personal settings. You will see the changes inside the iframe, everyone else will meanwhile see the default theme of the forum.

This is not a five-minute-task but it would have a significant positive effect to the user experience in case of the wanted changed link behaviour.

Please be aware that you will lose your changes in case of an update of the forum software (especially the changes in the functions) if you do not add further work into the preparation of the update procedure. Whenever you will update the forum software you have to check the namely functions for changes and have to reapply your changes to the functions. Same for changes in the main.tpl of the forum theme (even this will be not very often).

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!


Complete thread:

 RSS Feed of thread