[RC1] Prime Links - Classify Locals & Target Externals

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Get Involved
User avatar
primehalo
Former Team Member
Posts: 2997
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

This page gives several examples of custom BBCodes:
http://www.phpbb.com/community/viewtopi ... 6&t=579376
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
femu
Registered User
Posts: 1070
Joined: Tue Sep 27, 2005 10:03 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by femu »

Thanks a lot. That was more easy, than I thought ;)
Regards, femu
_____________________________________________
[My development page] - [My normal homepage (German only)]
updown
Registered User
Posts: 542
Joined: Sat Jan 05, 2008 6:53 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by updown »

Hello Primehalo, I just recognized a little xhtml-validation (mainly '&' instead of '&') glitch when using

EXTERNAL_LINK_PREFIX

The resulting link-structure is not xhtml-conform, due to the decode_entities() of the input link before without converting the entities back in $new_link.

This is the part with the new uncoded href: (from version 1.2.6)

Code: Select all

                if (!$is_local && $external_prefix)
                {
                    $external_prefix = (NO_EXTERNAL_LINK_PREFIX && preg_match('/\.(?:' . NO_EXTERNAL_LINK_PREFIX . ')(?:[#?]|$)/', $href)) ? '' : $external_prefix;
                    $new_link = str_replace('href="', 'href="' . $external_prefix, $new_link);
                } 
Maybe a better construct would be like this:

Code: Select all

                if (!$is_local && $external_prefix)
                {
                    $external_prefix = (NO_EXTERNAL_LINK_PREFIX && preg_match('/\.(?:' . NO_EXTERNAL_LINK_PREFIX . ')(?:[#?]|$)/', $href)) ? '' : $external_prefix;
                    $full_href = $external_prefix . $full_href;
                    $new_link = $this->insert_attribute('href', htmlentities($full_href), $new_link, true);
                }
  
Cheers!
User avatar
primehalo
Former Team Member
Posts: 2997
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

The decode_entities() function is only run on the $href variable, which is never actually used for the link. The $new_link variable is used, which does not have its entities decoded. When specifying an EXTERNAL_LINK_PREFIX value, then HTML entities need to be written out in their ampersand-coded form because I do not do anything to the EXTERNAL_LINK_PREFIX value, it's placed in the link as-is.

In your code, the $full_href = $external_prefix . $full_href; doesn't make sense because the $full_href doesn't yet exist.
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
updown
Registered User
Posts: 542
Joined: Sat Jan 05, 2008 6:53 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by updown »

Sorry, you're right, I modified the code and forgot about that...

I added $full_href before around line 300

Code: Select all

				$full_href = $href;
				$is_local = null;
Not quite sure why the problem with the entities exist on my side...

edit: OK, all clear, the problem was homemade - I did some functional changes and forgot about the half of them :geek:
User avatar
santhosh11421
Registered User
Posts: 47
Joined: Tue Jul 29, 2008 4:42 pm

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by santhosh11421 »

i was installed this mod , How can i hide links from guests ????????
User avatar
santhosh11421
Registered User
Posts: 47
Joined: Tue Jul 29, 2008 4:42 pm

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by santhosh11421 »

ok done .. found in previous posts .. thanks ..
iCloud
Registered User
Posts: 15
Joined: Fri Mar 26, 2010 10:52 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by iCloud »

How can I make it so it checks links inside the

Code: Select all

 tags?
User avatar
primehalo
Former Team Member
Posts: 2997
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

I am not aware of any simple way to do that .
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
nemmar
Registered User
Posts: 85
Joined: Mon Jun 13, 2005 2:07 pm

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by nemmar »

I've been using this Prime Links MOD for a few years and it works fine with opening all external links in a new window. However, I'm trying to get the MOD to open links to files in 4 subfolders on my domain to open in new windows. Here is what I tried with the code but it doesn't work. When I upload these changes to the server then my forum goes offline.

I changes the lines 337-342 in the file includes/prime_links.php

Code: Select all

if ($is_local && (strpos($href, 'asp-rel-articles-01') !== false || strpos($href, 'asp-rel-articles-02') !== false || strpos($href, 'asp-rel-articles-03') !== false || strpos($href, 'asp-rel-articles-04') !== false))
{
$new_target = EXTERNAL_LINK_TARGET;
} 
if ($new_target)
{
However, this is not working. Any suggestions on how to do this? The 4 subfolders/directories are:
asp-rel-articles-01, asp-rel-articles-02, asp-rel-articles-03, asp-rel-articles-04
User avatar
primehalo
Former Team Member
Posts: 2997
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

I don't see anything wrong with that code snippet. Looks like you may be using an older version of the MOD, though.
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
nemmar
Registered User
Posts: 85
Joined: Mon Jun 13, 2005 2:07 pm

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by nemmar »

Okay, I just installed the new version of the MOD and now it works. I realized that the problem was caused not by the version of the MOD, but instead by the editing software for the php files. When I edit my phpBB forum pages in my html editor I sometimes get the following errors display at the top of my board online:

[phpBB Debug] PHP Notice: in file /includes/session.php on line 1010: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:1)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1010: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:1)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1010: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3826: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3828: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3829: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:1)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3830: Cannot modify header information - headers already sent by (output started at /includes/functions_content.php:1)

The way I fix this is by using Notepad++ to edit the forum php pages. Apparently some html editors add some invisible spaces or characters/code to the php files when you edit them and it seems like it creates problems online. Is this a common problem, or is it just the html editor I'm using which is Microsoft Expression Web?
User avatar
primehalo
Former Team Member
Posts: 2997
Joined: Fri May 06, 2005 5:58 pm
Location: Redding, CA

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by primehalo »

Yes, it's a common issue. The invisible characters that are added by some editors are called Byte Order Marks (BOM).
Ken F. Innes IV
My Extensions | My MODs | My Topics | My Site: Absolute Anime
Experience the wonder of Japanese Animation!
femu
Registered User
Posts: 1070
Joined: Tue Sep 27, 2005 10:03 am

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by femu »

;)

You really should use Notepad++ for the HTML files too. MS is always doing things which noone expects .... :mrgreen:
Regards, femu
_____________________________________________
[My development page] - [My normal homepage (German only)]
nemmar
Registered User
Posts: 85
Joined: Mon Jun 13, 2005 2:07 pm

Re: [RC1] Prime Links - Classify Locals & Target Externals

Post by nemmar »

I have another question on updating my Prime Links code. I will be adding folders regularly that all will begin with the name of asp-rel-articles- and then a two digit number at the end of the name like, -05, -06, -07, etc.

Is there a way to adjust the Prime Links code so I have it set so all URL's on my domain with folder names beginning with asp-rel-articles- will open in new windows?

I can keep adding the new folders to the existing code update mentioned above since it works fine, but it wouuld be easier if I just had one entry for asp-rel-articles- and then I wouldn't need to make any new code updates for new folders.

Return to “[3.0.x] MODs in Development”