Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
relative address vs absolute address
#1
Hello,

i wanted to add some images in the sidebar component ... i have not figured out how to use the relative address and i ended up using absolute address

here is the prblem, for some reason, i have decided to change the webfolder name of my GetSimple website ... and now i need to update one by one these absolute addresses to the new address

furthermore i have noticed that all the links in my navigation menu are not automatically updated ... if i click on the meny link it will send to the old webfolder ...

do you have any suggestions?

many thanks
Reply
#2
Images - It depends where you store the files. If the images are on flickr obviously you use an absolute url
Code:
http://www.flickr.com/...
If the images are hosted with your GS site then you can use an absolute url
Code:
http://www.mysite.com/data/uploads/....
but if you ever want to move your site (or rename its folder) you will save yourself a lot of trouble by writing the url as
Code:
<?php get_site_url(); ?>data/uploads...
although you can't do that in page content, only in a component or in the template.

Relative urls in the html are a 'no no' because the page does not exactly exist as an html file in a fixed location in the directory structure on the server.

Nav links - sounds like you need to go to Settings in the Admin and enter the correct, new base url.
Reply
#3
As long as GS resides in root folder, it's safe to go with
PHP Code:
/data/uploads/<file
Also, you may find this relevant.

You can also edit /admin/settings.php, line 79 (GS 3.2.3) to have this
Code:
$SITEURL = tsl($_POST['siteurl']);
look like this
Code:
$SITEURL = '/';
This is an ugly core hack, but it'll generate most links (plugins may generate links differently) relatively to your GS root, so you can move the site from server to server whenever you want to.
Reply
#4
IMO it's better to patch GS so that it allows entering a relative-to-root site url in settings ("/", "/folder/", ...)

Edit /admin/settings.php and remove the type="url" in line 217 (GS 3.2.3)
Reply
#5
^ yup, this is way better, and makes more sense from user's point of view.
Reply
#6
(2013-11-22, 01:16:56)Carlos Wrote: IMO it's better to patch GS so that it allows entering a relative-to-root site url in settings ("/", "/folder/", ...)

Edit /admin/settings.php and remove the type="url" in line 217 (GS 3.2.3)

hello,

your suggestion applies only if GS in installed in the root folder i suppose ...
if i have semething like mydomain/siteA, my domain/siteB, mydomain/GetSimple and i want to remane the GS webfolder and take advantages of portability of relative addresses ... do u still suggest that patch?

many thanks
Reply
#7
You can't use Carlos' suggestion with your setup, unless you hack in core and dynamically add your host root to the $SITEURL global, but that's dodgy and may do more harm than good in the long run.

If it's possible for you to create and use subdomains then I'd suggest creating those and pointing them to your subfolders. This way all your GS instances can be placed "at root" and you can safely use Carlos' suggestion.
Reply
#8
(2013-11-20, 19:33:41)Timbow Wrote: [...]
but if you ever want to move your site (or rename its folder) you will save yourself a lot of trouble by writing the url as
Code:
<?php get_site_url(); ?>data/uploads...
although you can't do that in page content, only in a component or in the template.

i have used these suggestions and everything is fixed and i could easily rename the webfolder where GS is installed ...

but there was a little problem i could not fix ... i have some pages, such as About Us for instance that i dodnt add in the menu (the horizontal navigation links) and i would like to call it from the footer ... the footer i think is considered a component of the template and i have added

Code:
<a href="<?php get_site_url(); ?>about-us" >

but it does not work ... where is the mistake?

many thanks
Reply
#9
I just tested it and it works for me so I don't know. Must be a typo or mistake somewhere. If you look at the link in your browser in View Source is it correct? and the page slug is 'about-us' ?
Reply
#10
(2013-11-26, 19:09:06)Timbow Wrote: I just tested it and it works for me so I don't know. Must be a typo or mistake somewhere. If you look at the link in your browser in View Source is it correct? and the page slug is 'about-us' ?


my code inside footer.inc.php

Code:
<a href="<?php get_site_url(); ?>about-us" >About Us</a>

this is the output from View Sorce

Code:
<div class="wrapper">
            <div class="left">
                <a href="http://www.lifestyleandmore.it/finetoilets/about-us" >About Us</a>

and this is the Edit Page "About Us" - Page Options:

Code:
Custom URL (Slug):
about-us

thanks for helping
Reply
#11
I can see your pages and there seems nothing wrong with the link but when I click it I get a 404 Not Found which is not a GetSimple 404 and says
Quote:The requested URL /fineplaces/index.php was not found on this server.

what is /fineplaces/index.php ? How have you done that? It doesn't seem possible.
Reply
#12
(2013-11-26, 23:46:12)vdonatiello Wrote: my code inside footer.inc.php

Code:
<a href="<?php get_site_url(); ?>about-us" >About Us</a>

Address rewriting is not working on your site, either because you don't have it turned on, or because the standard settings don't work on Apache v2.4, or your hosting provider has not enabled it in the Apache configuration.

Make sure that you have something in (admin) Settings->Custom Permalink Structure (I would suggest %slug%) and clear the 'Use Fancy URLs' checkbox. Save settings.

If that doesn't work, for quick results, change your footer code to this:
Code:
<a href="<?php get_site_url(); ?>index.php?id=about-us" >About Us</a>
--
Nick.
Reply
#13
or (assuming about-us is a top level page with no parent):
Code:
<a href="<?php echo find_url('about-us',''); ?>">About Us</a>

This way the link will (always) use the current custom permalink structure.
Reply
#14
(2013-11-28, 19:47:56)hameau Wrote:
(2013-11-26, 23:46:12)vdonatiello Wrote: my code inside footer.inc.php

Code:
<a href="<?php get_site_url(); ?>about-us" >About Us</a>

Address rewriting is not working on your site, either because you don't have it turned on, or because the standard settings don't work on Apache v2.4, or your hosting provider has not enabled it in the Apache configuration.

Make sure that you have something in (admin) Settings->Custom Permalink Structure (I would suggest %slug%) and clear the 'Use Fancy URLs' checkbox. Save settings.


thanks hameau,
i have tried to add " %slug% " in the Custom Permalink Structure field and i made sure Use Fancy URLs is unchecked
but it didnt work :-(
thanks anyway
Reply
#15
(2013-11-29, 01:28:17)Carlos Wrote: or (assuming about-us is a top level page with no parent):
Code:
<a href="<?php echo find_url('about-us',''); ?>">About Us</a>

This way the link will (always) use the current custom permalink structure.


dear Carlos,
i don't understand PHP, i simply copied and pasted your suggestion and it works fine
many thanks
Reply




Users browsing this thread: 1 Guest(s)