Avatar

Installation de Mon Petit Forum (Design/Themes)

by ChristianForum, Monday, October 19, 2020, 06:37 (42 days ago)

Bonjour,
J'ai installé Mon Petit Forum dans une page de mon site afin qu'il bénéficie du même design que les autres pages. Pour cela, j'ai créé une page accueil.php dans laquelle je fais appel à index.php dans une iframe. Cela fonctionne très bien !
Il y a un problème lorsque dans un message il est fait appel à une page d'un site. Je voudrais que cette page s'ouvre dans un autre onglet et non dans iframe... Comment faire ?
Mon Petit Forum est sur cette page.

Traduction :

Hello, I have installed My Small Forum 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?

Avatar

Installation de Mon Petit Forum

by Auge ⌂ @, Monday, October 19, 2020, 08:07 (42 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!

Installation de Mon Petit Forum

by shian, Wednesday, October 21, 2020, 08:11 (40 days ago) @ Auge

Thank you Auge for the detailed explanation.
I've changed the file forum/includes/functions.inc.php (relying on the common law) and it works. (See forum post).

I wish that you could provide such detailed explanation for implementing the LTR-RTL BBcode manually. This is the only feature that I really need.

Thank you,
shian.

Avatar

Installation de Mon Petit Forum

by Auge ⌂ @, Monday, October 19, 2020, 11:16 (42 days ago) @ ChristianForum

Hello

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.

I wrote down a few more general thoughts about the issue in another thread.

Tschö, Auge

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

Avatar

Installation de Mon Petit Forum

by ChristianForum, Monday, October 19, 2020, 16:21 (42 days ago) @ Auge

Bonjour,
Lors de l'écriture d'un message qui doit comporter un lien, serait-il possible de laisser le choix : ouverture dans la même fenêtre ou bien ouverture dans une autre fenêtre ?
ChristianForum

Hello, When writing a message which must include a link, would it be possible to leave the choice: open in the same window or open in another window?;-)

Avatar

Installation de Mon Petit Forum

by Auge ⌂ @, Monday, October 19, 2020, 20:53 (42 days ago) @ ChristianForum

Hello

Hello, When writing a message which must include a link, would it be possible to leave the choice: open in the same window or open in another window?;-)

No, you'll haven't this choice.

Tschö, Auge

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

Avatar

Installation de Mon Petit Forum

by ChristianForum, Wednesday, October 21, 2020, 09:37 (40 days ago) @ Auge

Bonjour,
En effet, actuellement, cela n'est pas possible d'avoir le choix lors de l'édition du message. Mon propos était une suggestion à intégrer lors d'une future mise à jour :-D

--
Cordialement,
ChristianForum

RSS Feed of thread

powered by my little forum