Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
relative urls in images and internal links
#1
I am creating a website on my localserver (xampp) having about 170 pages and about 500 pics. There are about 50 pages in the menu and the other pages are internally linked in the text through the WYSIWYG Editor.

Now when I upload this to the online server all the internal links and the images paths will still be using the http://localhost/getsimple path. So I'll have to manually edit all these references (albeit in bulk inside a text editor like Notepad++ or PSPad) before I upload the site.

Is there any way that the internal links and the images can use a relative path from the siteroot and pick up the siteroot from the .htaccess file or the Settings page inside Admin? This would really be a great timesaver.
Reply
#2
ckeditor by default uses relative paths.
I didn't have such problems with latest GS3.1 when I moved websites between different servers.
Addons: blue business theme, Online Visitors, Notepad
Reply
#3
yojoe Wrote:ckeditor by default uses relative paths.
I didn't have such problems with latest GS3.1 when I moved websites between different servers.

yojoe, I am not so sure.
Please check the source code of a page after editing it in CKEditor, it stores absolute paths...

if not, how did you define that?
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#4
Do you remember those threads Connie ?
http://get-simple.info/forum/topic/487/c...-ckeditor/
http://get-simple.info/forum/topic/2113/...-ckeditor/
Since then ckeditor uses relative paths.

To be 100% sure I changed twice location of theme I developed, and everything works fine. Both images, and links.
Addons: blue business theme, Online Visitors, Notepad
Reply
#5
yojoe,

thanks for the hints to these posts. I see that I got stuck in the middle of the road ;=)

So I will experiment again this weekend!

tshenkuje ;=)
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#6
This is good to know.

Do we know when this was changed/ which ckeditor update?
GS 3.1 ?

This was a pet peeve of mine, the absolute paths.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#7
I tried the following solution

Change line 24 of filebrowser.php from

$fullPath = $sitepath . "data/uploads/";

to

$fullPath = "data/uploads/";

but it doesn't work even for root level pages.

If my page is named 'testing' and an image inserted from 'data/uploads/image1.jpg'

The live page tries to look for the image path as http://localhost/getsimple/testing/data/uploads/image1.jpg'.

Any other suggestions?
Reply
#8
andyash Wrote:but it doesn't work even for root level pages.

If my page is named 'testing' and an image inserted from 'data/uploads/image1.jpg'

The live page tries to look for the image path as http://localhost/getsimple/testing/data/uploads/image1.jpg'.

Any other suggestions?
I wonder what went wrong after you pushed your webiste to production environment and changed RewriteBase path in htaccess and site's url in GS settings.
Try another approach, follow up migration migration steps described in wiki http://get-simple.info/wiki/installation:migrating
The simplest way in 3 steps:
1. install GS on production server
2. copy /data directory from localhost
3. configure GS the way you did it on localhost
It has to work, unless your production environment doesn't meet GS minimum requirements.

Shawn: I think it has been added when gs 2.04B was going to be published as 3.0
Addons: blue business theme, Online Visitors, Notepad
Reply
#9
I don't see this as fixed.

I still see absolute urls, just as andyash posted.
Insert images, browse server, click image i file browser.
check source, absolute url.

And that code change is wrong, it changes it to relative to page slug, you need relative to site root.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#10
shawn_a,

I support you
that was the result of my last tries and errors Wink(
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#11
This works for me

Code:
$sitepath = suggest_site_path(true);
$fullPath = $sitepath . "/data/uploads/";
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#12
I found the thing I forgot to mention, after Shawn came up with calling suggest_site_path(true).
While adding images to content I was always deleting part of the url, and since I came across problems with my webhost, I had a ready to copy, modified basic.php file. Where among couple things I had a changed function suggest_site_path($parts=false) inside basic.php, which returned $path_parts in both cases.
Thus the returned link to img was always relative.

But this isn't a solution for a ready to migrate website. Now the only way is to bulk edit&replace strings in all pages xml files.

I'm terribly sorry for misleading.
Addons: blue business theme, Online Visitors, Notepad
Reply
#13
yojoe Wrote:I found the thing I forgot to mention, after Shawn came up with calling suggest_site_path(true).
While adding images to content I was always deleting part of the url, and since I came across problems with my webhost, I had a ready to copy, modified basic.php file. Where among couple things I had a changed function suggest_site_path($parts=false) inside basic.php, which returned $path_parts in both cases.
Thus the returned link to img was always relative.

But this isn't a solution for a ready to migrate website. Now the only way is to bulk edit&replace strings in all pages xml files.

I'm terribly sorry for misleading.

Yeah i think that function is bugged, it doesn't actually return parts, it returns a string.
I am not sure what its supposed to do however.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#14
So we are back to where we began. I think there is a burning need to make relative urls (for images as well as internally linked pages) work.

Do we need to put this in as a feature request?
Reply
#15
What do other CMSs (WP, etc.) do about this?
I don't think there's a failproof way to do... (except using some kind of token in page content...)
Reply
#16
Carlos Wrote:What do other CMSs (WP, etc.) do about this?
I don't think there's a failproof way to do... (except using some kind of token in page content...)

It showed off that absolute paths were not ckeditor's problem, but GS function we mentioned.
Best thing would be to tweak this function, and add a new gsconfig value:
Code:
# Turn on absolute urls
#define('absoluteurls', TRUE);
This way relative paths would be a default option.
Addons: blue business theme, Online Visitors, Notepad
Reply
#17
yojoe Wrote:
Carlos Wrote:What do other CMSs (WP, etc.) do about this?
I don't think there's a failproof way to do... (except using some kind of token in page content...)

It showed off that absolute paths were not ckeditor's problem, but GS function we mentioned.
Best thing would be to tweak this function, and add a new gsconfig value:
Code:
# Turn on absolute urls
#define('absoluteurls', TRUE);
This way relative paths would be a default option.

Yeah but where do you make the paths relative to ?
Current page works 99% of the time because GS uses a single page system, but there is a possibility for it to break if some plugin or future change uses a different path, maybe those could use baseref, but that can get sloppy.

maybe relative to siteroot
/path

At least its domain portable
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply
#18
How about relative urls to:
Code:
RewriteBase /directory/
set up upon installation, and handled in one variable inside gsconfig ?
Addons: blue business theme, Online Visitors, Notepad
Reply
#19
Other CMSs. Let's see... I have worked with other flatfile CMSs like Pluck CMS, Razor CMS, SkyBlueCanvas etc and never faced a problem with any of them. Pluck works out of the box in its offline and online version with no changes required. Razor and Skybluecanvas just needed the htaccess file and one xml file containing the site root information changed. All the internal links and image paths worked with no changes required.

I am not a programmer so I don't know what they did to achieve this, but I guess one of you guys will be able to located the code.
Reply
#20
Do those other CMSs support fancy and custom URLs with possible different levels (parent, parent/child) like GetSimple?

WordPress has the same problem as GS, so its links to pages, images, etc. are all absolute. If you change domain or/folder you have to:

- do a search/replace to update the links in the database, or
- use a plugin like this.

Also with WP, I think that another possibility is using shortcodes for local links (from the beginning).

Another comment on this subject:

There's a way to make GS use semi-relative URLs (or absolute URIs, if you prefer) to make it easy to change hosts: Ed at ISI's method with GS 3.0 (with 3.1 you have to edit the site.xml file or patch the core)
Reply
#21
Carlos Wrote:Do those other CMSs support fancy and custom URLs with possible different levels (parent, parent/child) like GetSimple?
They do. I don't want to touch the core files, so I guess I'll have to live with search/replace.
Reply
#22
andyash Wrote:
Carlos Wrote:Do those other CMSs support fancy and custom URLs with possible different levels (parent, parent/child) like GetSimple?
They do. [...]

Do you know how they store <a href=...> and <img src=...> links in the data files (xml or whatever)?
(I ask because I have no time right now to research... I'll do, I'm curious about this)

If they really support different folder levels, they must be using some kind of shortcode system, not just raw html content like GS (and WP).
Reply
#23
shawn_a Wrote:I don't see this as fixed.
Shawn, Mike: has the problem with relative urls been resolved since GS3.1 ?
Addons: blue business theme, Online Visitors, Notepad
Reply
#24
did we agree that changing line 26 of filebrowser.php to

Code:
$sitepath = suggest_site_path(true);

works or not??

Seems to work fine for my systems..
My Github Repos: Github
Website: DigiMute
Reply
#25
n00dles101 Wrote:did we agree that changing line 26 of filebrowser.php to

Code:
$sitepath = suggest_site_path(true);

works or not??

Seems to work fine for my systems..

This seems to work fine for me too, as long as I add a "/" before "data" on lines 27 & 167


GS Community Edition with php8.x compatibility, new features and much more!  Support Me


Reply




Users browsing this thread: 5 Guest(s)