Home
Download
Add-ons
Help
Forum
Organisation
Project
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 26, 2012, 03:50:51 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter
hier
und auf unserer
neuen Webseite
.
155543
Posts in
21714
Topics by
7737
Members
Latest Member:
simpleguy3
WebsiteBaker Community Forum
English
Modules
(Moderator:
Argos
)
WYSIWYG Editors and relative links
Pages: [
1
]
Go Down
Author
Topic: WYSIWYG Editors and relative links (Read 742 times)
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2297
WYSIWYG Editors and relative links
«
on:
March 12, 2011, 11:35:15 PM »
Just had a little brainwave.
We all know the problem of images in WYSIWYG pages that include the full url. When moving the site from the development server to a live server the images are still pointing to the development server.
It is very hard (if not impossible) to change the editors on this. They need to know the full url to be able to load the plugins and give the possibility to browse images and other stuff.
All WYSIWYG editors work through the WYSIWYG module. So why not remove the full url at that point before it is saved in the database.
The experimental fix:
The WB2.8.1 WYSIWYG module "save.php" reads in line 30 the data posted when saving the data.
If I just add the following code on line 31, all links to my own server (defined in WB_URL) will be transformed in links without the server.
Code:
$content = str_replace ( '"'.WB_URL, '"', $content);
I quickly tested this on one of my development sites and it seems to do the trick.
A line that now says
<img src="
http://myserver.com/media/image.jpg
" />
is nicely transormed in
<img src="/media/image.jpg" />
There might be side-effects to this, so please test this "hack", and report any issues in this topic.
Maybe we can finetune this to a full solution.
Ruud
«
Last Edit: March 12, 2011, 11:37:05 PM by Ruud
»
Logged
Professional WebsiteBaker Solutions
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4884
Re: WYSIWYG Editors and relative links
«
Reply #1 on:
March 12, 2011, 11:40:55 PM »
Hoi Ruud.
I can see that you'll get in troubles with pages on level > 0.
Regards,
Stefek
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2297
Re: WYSIWYG Editors and relative links
«
Reply #2 on:
March 12, 2011, 11:46:37 PM »
Quote from: Stefek on March 12, 2011, 11:40:55 PM
I can see that you'll get in troubles with pages on level > 0.
Naah..
The WB_URL should have no / at the end, so the remainer will start with the /
Brainwaiving further
I can see problems with sites installed in a subdirectory.
If WB_URL is set to
http://myserver.com/wb
this will not work
Especially if you move to a live server without the subdirectory.
Logged
Professional WebsiteBaker Solutions
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4884
Re: WYSIWYG Editors and relative links
«
Reply #3 on:
March 12, 2011, 11:52:02 PM »
Hello Ruud,
Maybe you can combine your Ideas with thoese both snippets:
http://www.websitebaker2.org/forum/index.php/topic,20575.msg139365.html#msg139365
http://www.websitebaker2.org/forum/index.php/topic,20841.msg140994.html#msg140994
The second link works fine,
but the links are not yet "relative".
Regards,
Stefek
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2297
Re: WYSIWYG Editors and relative links
«
Reply #4 on:
March 13, 2011, 12:07:45 AM »
Ok, the word "relative" is relative here..
On saving we should check the level of the current page, remove the WB_URL part and replace it with a series of "../" depending on the current pagetree level.
Let me sleep on that for now..
Logged
Professional WebsiteBaker Solutions
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4884
Re: WYSIWYG Editors and relative links
«
Reply #5 on:
March 13, 2011, 12:29:49 AM »
sorry stefek... i clicked the wrong button...
werner
«
Last Edit: March 13, 2011, 02:17:49 PM by DarkViper
»
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
DarkViper
Development Team
Offline
Posts: 1253
Re: WYSIWYG Editors and relative links
«
Reply #6 on:
March 13, 2011, 02:16:33 PM »
there is already a solution in wysiwyg-module from 2.9 SVN.
the solution is based on Document_Root and will affect links only which are inside HTML markups as href or src. Like <img><object><a> and so on, but never change links written in plain text.
to adapt this module for 2.8.x the file /framework/initialize.php needs following additional lines at the end:
(it's a private patch only, not an official solution)
Code: (/framework/initialize.php)
<?php
...
...
if(!
defined
(
'MEDIA_URL'
))
define
(
'MEDIA_URL'
,
WB_URL
.
MEDIA_DIRECTORY
);
$tmp
=
str_replace
(
'\\'
,
'/'
,
$_SERVER
[
"DOCUMENT_ROOT"
]);
$tmp
=
str_replace
(
$tmp
,
''
,
str_replace
(
'\\'
,
'/'
,
WB_PATH
));
if(!
defined
(
'MEDIA_REL'
))
define
(
'MEDIA_REL'
,
$tmp
.
MEDIA_DIRECTORY
);
?>
have a nice day...
«
Last Edit: March 13, 2011, 02:20:53 PM by DarkViper
»
Logged
Anleitungen lesen und selber nachdenken ist anstrengend... Da lass ich doch lieber andere für mich denken...
In
1984
: Nineteen Eighty-Four is a unrealistic utopia!!
In
2012
: Nineteen Eighty-Four is a little piece only of our reality!!
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4884
Re: WYSIWYG Editors and relative links
«
Reply #7 on:
March 13, 2011, 07:20:57 PM »
Quote from: Stefek on March 13, 2011, 12:29:49 AM
sorry stefek... i clicked the wrong button...
werner
This can happen.
Nevermind.
Thanks for that patch.
It works if I put it right into the WYSIWYG Editor view.php
Code:
<?php
// define constants MEDIA_URL, MEDIA_REL if not allready defined
if(!
defined
(
'MEDIA_URL'
))
define
(
'MEDIA_URL'
,
WB_URL
.
MEDIA_DIRECTORY
);
$tmp
=
str_replace
(
'\\'
,
'/'
,
$_SERVER
[
"DOCUMENT_ROOT"
]);
$tmp
=
str_replace
(
$tmp
,
''
,
str_replace
(
'\\'
,
'/'
,
WB_PATH
));
if(!
defined
(
'MEDIA_REL'
))
define
(
'MEDIA_REL'
,
$tmp
.
MEDIA_DIRECTORY
);
//.... and then ...
if(
strpos
(
$content
,
'{SYSVAR:MEDIA_REL}'
))
$content
=
str_replace
(
'{SYSVAR:MEDIA_REL}'
,
MEDIA_REL
,
$content
);
Should do the same trick as putting it into the
framework/initialize.php
, right?
Regards,
Stefek
«
Last Edit: March 13, 2011, 07:22:55 PM by Stefek
»
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
Stefek
WebsiteBaker Org e.V.
Offline
Posts: 4884
Re: WYSIWYG Editors and relative links
«
Reply #8 on:
March 13, 2011, 08:04:16 PM »
By the way, Werner.
This replacement
Code:
<?php
if(
strpos
(
$content
,
'{SYSVAR:MEDIA_REL}'
))
$content
=
str_replace
(
'{SYSVAR:MEDIA_REL}'
,
MEDIA_REL
,
$content
);
could be part of the $wb->preprocess() method, right?
Regards,
Stefek
Logged
"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
DarkViper
Development Team
Offline
Posts: 1253
Re: WYSIWYG Editors and relative links
«
Reply #9 on:
March 13, 2011, 08:23:21 PM »
Quote
Should do the same trick as putting it into the framework/initialize.php, right?
implicitly putted that patch into the initialize.php so no changes are needed in the module from wb2.9 (i.e. some later updates)
in modify.php and save.php the new constant MEDIA_URL is needed too.
Quote
could be part of the $wb->preprocess() method, right?
this toggeling between MEDIA_URL {PLACE_HOLDER} and MEDIA_REL is a complete functionality of the module wysiwyg. It should not be distributed to completely different functionalities. Whats happen, if in future the preprocess() will be changed into any other thing? who will remember the dependence to wysiwyg??
Logged
Anleitungen lesen und selber nachdenken ist anstrengend... Da lass ich doch lieber andere für mich denken...
In
1984
: Nineteen Eighty-Four is a unrealistic utopia!!
In
2012
: Nineteen Eighty-Four is a little piece only of our reality!!
crnogorac081
AddOn Development
Offline
Posts: 1706
Re: WYSIWYG Editors and relative links
«
Reply #10 on:
March 13, 2011, 09:41:53 PM »
Hi Ruud,
I had an idea for this too.
Take a look at my solution:
http://www.websitebaker2.org/forum/index.php/topic,20841.0.html
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Ruud
WebsiteBaker Org e.V.
Offline
Posts: 2297
Re: WYSIWYG Editors and relative links
«
Reply #11 on:
March 13, 2011, 11:03:22 PM »
Good to see I am not the only one brain-waving about this.
Being the biggest supporter of droplets, I do not like the droplet solution. It makes a module dependent of the existence of a certain droplet.
I like the MEDIA_REL approach. This could be simply built in the ( WB2.8 ) WYSIWYG module to make it work for WB2.8 users too.
Logged
Professional WebsiteBaker Solutions
crnogorac081
AddOn Development
Offline
Posts: 1706
Re: WYSIWYG Editors and relative links
«
Reply #12 on:
March 14, 2011, 10:35:07 AM »
Quote from: Ruud on March 13, 2011, 11:03:22 PM
Being the biggest supporter of droplets, I do not like the droplet solution. It makes a module dependent of the existence of a certain droplet.
I agree, but it looked to me as a simple solution and backward compatible than using ..SYSVAR:MEDIA_REL.. etc..
I add [[WB-URL]] to droplets first thing I install wb
I would also suggest to add it as a default droplet
cheers
Logged
Wow, I coded something myself: PM Messanger Modul ,Searchbox with suggestions
Pages: [
1
]
Go Up
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General Announcements
=> Security Announcements
=> Documentation
=> WebsiteBaker Website Showcase
=> Guest Area & Off-Topic
-----------------------------
English
-----------------------------
=> WebsiteBaker 2.9
===> Announcements
===> Help/Support
=====> Modules / Extensions
===> Suggestions
===> Software bugs
=> Help & Support
=> Modules
=> Droplets (PHP code for use with Droplet module) & Snippets (raw PHP code)
=> jQuery
=> Templates, Menus & Design
=> WebsiteBaker Language Files
=> WebsiteBaker 2.x discussion
=> WebsiteBaker 3
=> Archive (posts up to 2007)
-----------------------------
Deutsch (German)
-----------------------------
=> Ankündigungen
=> WebsiteBaker 2.9
===> Ankündigungen
===> Hilfe/Support
=====> Module / Extensions
===> Vorschläge
===> Softwarefehler
===> Erfahrungs und Testberichte
=> Hilfe/Support
=> Module & Snippets
=> Templates & Design
=> Tutorials
=> jQuery
=> Diskussion über WB
=> Off-Topic
=> Archiv für Themen bis 2007
-----------------------------
Nederlands (Dutch)
-----------------------------
=> Aankondigingen
=> Hulp & Ondersteuning
=> Niet-Terzake (Off Topic)
-----------------------------
Francais (French)
-----------------------------
=> Help/Support
-----------------------------
Italiano (Italian)
-----------------------------
=> Help/Support
-----------------------------
Bakery (WB shop module)
-----------------------------
=> Bakery English
=> Bakery Deutsch
-----------------------------
KeepInTouch (Multi Contact Module)
-----------------------------
=> KeepInTouch English
=> KeepInTouch Deutsch
Loading...