Welcome Guest, Not a member yet? Register   Sign In
Paths with WYSIWYG generated content
#1

[eluser]ralf57[/eluser]
Can anybody give some tips on how to properly deal with the urls and paths stored from WYSIWYG powered texareas?
I mean:
Code:
<img src="my_image.ext" />
<a href="my_url"></a>
...
I understand that absolute urls/path should be avoided, but what to save to ensure, for example, painless migration from development to production server?
Example from:
http://localhost/dev/ci/files/
to
http://www.mysite.com/files/
Thanks in advance
#2

[eluser]pistolPete[/eluser]
[quote author="ralf57" date="1252696592"]I understand that absolute urls/path should be avoided[/quote]

Why should they be avoided?

Just use absolute paths like this (notice the / at the beginning):

Code:
<img src="/path/to/your/image.ext" />
#3

[eluser]ralf57[/eluser]
[quote author="pistolPete" date="1252709113"]
Why should they be avoided?

Just use absolute paths like this (notice the / at the beginning):

Code:
<img src="/path/to/your/image.ext" />
[/quote]

This is actually a relative (to the root of the web server) path, not absolute.
An absolute path/url is like this:

Code:
<img src="http://localhost/dev/ci/files/image.ext" />
or
Code:
<img src="http://www.mysite.com/files/image.ext" />

The problem occurs when you have a development installation in a sub-directory of the web server root (very frequent case).
You cannot store neither this
Code:
http://localhost/dev/ci/files/image.ext
nor this
Code:
/dev/ci/files/image.ext
Unless the directory structure in the production installation is the same as the development,
you'll get broken paths/urls.
How to face this issue?
#4

[eluser]jedd[/eluser]
Quote:How to face this issue?

Use the [url="http://ellislab.com/codeigniter/user-guide/helpers/html_helper.html#img"]img()[/url] function.
#5

[eluser]ralf57[/eluser]
[quote author="jedd" date="1252813622"]
Use the [url="http://ellislab.com/codeigniter/user-guide/helpers/html_helper.html#img"]img()[/url] function.[/quote]

I can't since I will be storing in the DB the markup sumbitted via an WYSIWYG editor, so pure (X)HTML.
#6

[eluser]jedd[/eluser]
It seems to me that you need to translate the urls/paths as your 'wysiwyg' data enters/exits your database, or you resolve yourself to data that only works from a specific server/directory.

Do you store the full URI of all elements in your marked-up text in your database now?
#7

[eluser]renownedmedia[/eluser]
I set up a vhosts for this exact issue and use http://rvgui instead of http://localhost/rvgui. Click the blog link in my sig and search for vhosts for a tutorial
#8

[eluser]ralf57[/eluser]
@jedd
No, I actually don't have any content inserted but the I will not use absolute paths

@thomas
The vhosts solution is reliable but needs a bit of setup to work.
Furthermore it doesn't suit in case you have, for some reason, move the production installation from a directory to another.
For example:
From http://www.myhost.com to http://www.myhost.com/newsite/
#9

[eluser]jedd[/eluser]
[quote author="ralf57" date="1253021748"]@jedd
No, I actually don't have any content inserted but the I will not use absolute paths
[/quote]

I'm confused. Earlier you're talking about how to work around the problem of coping with changes to your path that you want to store, and now you're saying you're not storing absolute paths.

Perhaps it might be easier if you actually spell out what you *are* intending (or at least want) to store.
#10

[eluser]kurucu[/eluser]
Agreed with Jedd....

But perhaps &lt;base href="http://path/to/CI/" /&gt; addresses your problem? I am guessing because (see Jedd's post).




Theme © iAndrew 2016 - Forum software by © MyBB