Internal links stored as relative

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier

Internal links stored as relative

Post by javiexin »

Hi,

I would like to know if it is possible to store the links (URLs) from posts to other parts of the forum as relative to the forum base, rather than as full URLs with domain. This way, when the forum is migrated to a different domain (or replicated for testing purposes, for example), or even when creating a local copy of the forum, these links are fully functional within the copy.

Any recommendation? Thanks,
-javiexin

PS: Didn't know where to put this, as it is neither a support request nor a mod request, nor a Mod Writers discussion... Maybe an enhancement request to the core :) If any moderator feels this is not the place, please correct my error.
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Internal links stored as relative

Post by 4_seven »

javiexin wrote:I would like to know if it is possible to store the links (URLs) from posts to other parts of the forum as relative to the forum base, rather than as full URLs with domain. This way, when the forum is migrated to a different domain (or replicated for testing purposes, for example), or even when creating a local copy of the forum, these links are fully functional within the copy.
Ehm, that is phpbb3 standard

see this link

http://www.phpbb.com/community/viewforum.php?f=72

Code: Select all

http://www.phpbb.com/community/viewforum.php?f=72
Current Mods | Mod Base | php(BB) programming | No help via PM
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53609
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Internal links stored as relative

Post by Brf »

Make a custom bbcode:

Code: Select all

[RURL={LOCAL_URL}]{TEXT}[/RURL]

Code: Select all

<a href="{LOCAL_URL}">{TEXT}</a>
4_seven wrote:Ehm, that is phpbb3 standard

see this link

http://www.phpbb.com/community/viewforum.php?f=72
No. That is stored with phpbb.com in the text. If you migrated this board to another domain, it would stop working.
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Internal links stored as relative

Post by 4_seven »

than you can make a very simple sql and change phpbb.com to xyz.net in the database.
costs 5 minutes..

http://www.phpbb.com/community/viewtopi ... #p12084535
Current Mods | Mod Base | php(BB) programming | No help via PM
User avatar
Brf
Support Team Member
Support Team Member
Posts: 53609
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}

Re: Internal links stored as relative

Post by Brf »

Perhaps, but that is not what this topic is asking.
It is asking how to store the link as relative, as you can see by the Subject.
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Internal links stored as relative

Post by 4_seven »

so, it makes only sense, when you do this or a basic solution (may in bbcode.php) from the very beginning, on a fresh board ;)
Current Mods | Mod Base | php(BB) programming | No help via PM
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier

Re: Internal links stored as relative

Post by javiexin »

Thanks to both.

The custom BBCode if of course a possible solution for future links, but that doesn't prevent any user to post a link using the standard URL BBCode with a local link, breaking the intent.

Whatever the solution should be automatic.

I guess it should not be too complicated, because the links may be classified, as it is done in the Prime Links MOD... but I am sure there are some things that escape me.
The issue is how to store it correctly in database (yes, I had already seen this post http://www.phpbb.com/community/viewtopi ... #p12084535 when searching for potential solutions before I posted here, so I know how to change it from one domain to other), and behave properly when editing posts or when adding extra links, so I guess some changes either in bbcode.php and/or posting.php may be required, and maybe even in other places I do not ancipate.

Any further ideas?
-javiexin
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Internal links stored as relative

Post by 4_seven »

a full solution will not be ready this night, so chill out..
Current Mods | Mod Base | php(BB) programming | No help via PM
User avatar
canonknipser
Registered User
Posts: 2096
Joined: Thu Sep 08, 2011 4:16 am
Location: Germany
Name: Frank Jakobs

Re: Internal links stored as relative

Post by canonknipser »

There is an RCF over at Area 51: http://area51.phpbb.com/phpBB/viewtopic ... 84&t=33021

I think it will be a good idea to post your request there. Internal links are discovered by the bbcode-engine and given a class="postlink-local" attribute, so it should be quite easy to convert them to relative links.
Greetings, Frank
phpbb.de support team member
English is not my native language - no support via PM or mail
New arrival - Extensions and scripts for phpBB
User avatar
javiexin
Code Contributor
Posts: 1157
Joined: Wed Oct 12, 2011 11:46 pm
Location: Madrid, Spain
Name: Javier

Re: Internal links stored as relative

Post by javiexin »

Thanks canonknipser,

As far as I can tell (please, correct me if I am wrong), adding the postlink-local class is only done to magic URLs (ie, URLs not within the URL BBCode or any other BBCode for that matter). For all URLs that are within the URL BBCode, the postlink CSS class is used regardless of whether it is a local link or not, and for other (custom) BBCodes nothing is done (ie, no processing/class assignment).

Anyhow, as you say, this is already identified, so feasible.

Regarding the RFC, I see it as with a much broader scope (rewritting the BBCode engine), and this is a more detailed issue. Nevertheless, I will try to post it there just in case.

Thanks again,
-javiexin

Return to “[3.0.x] MOD Requests”