Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-02-27 03:20:13

dandul
Member
From: Brisbane, Australia
Registered: 2010-01-31
Posts: 33

link problems when i move to a subdirectory

Hi, I have a fully functioning txp site (http://www.meditationinadelaide.com.au/) that I’m porting to another site for them to use for themselves.

But when I moved it to a subdirectory on their website (http://meditateinnewcastle.org/NEW/) a lot of the links stopped working. But not all.

The problem seems to be that links in the article have http://meditateinnewcastle.org/ put in front of them but not NEW/ so they don’t work.

For example (http://meditateinnewcastle.org/NEW/evening-classes/semaphore-meditation-classes): an image called in using the article image tag appears. But lower down an image that I called from the body of the text ( <img src=”/images/38.jpg” etc ) doesn’t.

The menu-links work but again when I have links in the articles they don’t. they too lack the reference to the subdirectory NEW.

I uploaded the same installation to another website this time straight in the public_html folder and it worked fine (http://www.codd.info/evening-classes/semaphore-meditation-classes)

Does anyone know what might be causing this? I’ve played with the preferences settings and didn’t have any joy.

Thanks!


Stop wishing things were different to the way they are. Accept it, deal with it, move on.

Offline

#2 2010-02-27 04:19:46

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: link problems when i move to a subdirectory

dandul wrote:

But lower down an image that I called from the body of the text ( <img src=”/images/38.jpg” etc ) doesn’t.

Kelsang, Textpattern won’t (either can’t) change the paths that are hard-coded inside articles or forms :-)

If you use textile to output the image (like !images/38.jpg!), it will automatically generate the site path into the url if you leave the prepending slash out. Because XHTML is generated from Textile only during the article save, you will have to resave the articles, so that it refreshes the markup and urls. For example !images/38.jpg! generates <img src="http://example.com/images/38.jpg" alt="" /> and !/images/38.jpg! generates <img src="/images/38.jpg" alt="" />.

In the future you can also try to use Textpattern tags. TXP has some tags that will help you to build URLs and navigations that will upkeep the correct structure. See Tag Reference. Like:

<img src="<txp:site_url />images/38.jpg" alt="" />

Last edited by Gocom (2010-02-27 04:41:06)

Offline

#3 2010-02-27 05:12:37

dandul
Member
From: Brisbane, Australia
Registered: 2010-01-31
Posts: 33

Re: link problems when i move to a subdirectory

Thanks Gocom. I had a feeling that would be the answer. Oh well, a chance to learn something new. Thanks for your tag suggestions, now is the perfect opportunity to practice them! :)

Cheers


Stop wishing things were different to the way they are. Accept it, deal with it, move on.

Offline

#4 2010-02-27 12:46:56

dandul
Member
From: Brisbane, Australia
Registered: 2010-01-31
Posts: 33

Re: link problems when i move to a subdirectory

Hi

I did find a workaround to moving a site to a folder inside the public_html folder and then having links fail because I used relative links like this:

<img src=”/images/38.jpg" alt="" /> 
<a href="/subscribe-to-our-newsletter">Sign up for the Newsletter</a>

instead of absolute links like this:

<img src="<txp:site_url />images/38.jpg" alt="" />
<txp:article_custom id="4"><txp:permlink><txp:title /></txp:permlink></txp:article_custom>

You create a subdomain on your server (I did it through CPanel) and call it something – I called it “new”. This creates a URL www.new.mywebsite.com.

Copy the txp site to that folder.

In txp preferences page the site URL would be – new.mywebsite.com

In advanced preferences the file location is – /home/username/public_html/new/files

Temp folder is – /home/username/public_html/new/textpattern/tmp

Then when you’re finished testing you can move the site out to the public_html folder, update the txp preferences and it’s done!

Hope that’s useful.


Stop wishing things were different to the way they are. Accept it, deal with it, move on.

Offline

#5 2010-03-09 03:43:28

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: link problems when i move to a subdirectory

I’m having a linkage problem with my custom links. I’d like to find out how to avoid using the full path (i.e.: http://mywebsite.com/images/555.jpg).

Background:
I’ve customized my template to have my design art/image items within my images folder on my server. However, the links get lost in certain circumstances.

Example: On the Home page the links work as they should, but I find I have to give it a root path (I’m working from my local host right now) such as:
<a href=“http://localhost/example.dev/Services/”><img src=“images/elements/ads/housing.jpg” alt=“Go to Access to Housing for Health” border=“0” /></a>

However, on the Articles page I have to do the following to the images location: <img src=”../images/elements/ads/housing.jpg” alt=“Go to Access to Housing for Health” border=“0” /></a>
And if you click the article, the page views but the art is lost even with the …/ tag.

If, however, I resort to the full path: /”><img src=” http://localhost/example.dev/images/elements/ads/housing.jpg” alt=“Go to Access to Housing for Health” border=“0” /></a> the image (naturally) will appear in every instance.

How can I avoid using the full path?

Thanks!

Last edited by laptophobo (2010-03-09 03:44:04)


Living the Location-Independent Life: www.NuNomad.com

Offline

#6 2010-03-09 06:42:56

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,251
Website GitHub Mastodon Twitter

Re: link problems when i move to a subdirectory

laptophobo wrote:

How can I avoid using the full path?

using Jukka’s suggestion uses the full path but as it is using txp tags it is dynamic which makes migration easier.

So <img src="<txp:site_url />images/elements/ads/housing.jpg" alt="Go to Access to Housing for Health" border="0" /></a> should work.

Last edited by colak (2010-03-09 06:46:08)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2010-03-09 07:09:26

laptophobo
Member
Registered: 2010-03-01
Posts: 216
Website

Re: link problems when i move to a subdirectory

Beautiful, Perfect! Can’t thank you enough.


Living the Location-Independent Life: www.NuNomad.com

Offline

Board footer

Powered by FluxBB