Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-06-05 10:47:25
- minusf
- Member
- Registered: 2005-02-15
- Posts: 104
[textile] absolute vs relative url generating
hi there,
i have moved 2 txp sites recently, and it can be quite a challenge.
i think it could be much more easier with some minor changes
in txp. admittedly, moving is not an every day issue, but why
not make it easier?
as of 4.0.4 txp generates absolute urls for images and downloads.
this makes moving very hard without doing mysql voodoo, and
i still wouldn’t sleep soundly.
one solution would be to make it possible to use implicitly
<txp:link_to_home/>
for local images and downloads.
but another one, even easier is just to use relative urls.
consider the following example:
"take this":http://example.com/file_download/1
vs
"take this":file_download/1
or
!http://example.com/images/349.jpg!
vs
!images/349.jpg!
it is the same. except that the second one is trivial to work
with if moving the site: leave it alone.
(this works even without a docbase directive.
but it could be added anyway if one wishes to.)
the problem is to explain this to non-technical editors.
putting a switch on all the tag generating popups is not
very practical i think, so there could be a global switch
for generating relative urls, or generating absolute urls,
depending on preference, and generating absolute urls
by default of course to be backwards compatible.
we is experts™
Offline
Re: [textile] absolute vs relative url generating
I think relative URLs would cause more problems then they solve. Suppose your images are in /images.
Front page: images/1.jpg
Permalinked page: ../../images/1.jpg
However, I am in favor of loosing the domain part of the URL in the tag generators. That does have some advantages and no downsides, as far as I can tell: /images/349.jpg
instead of http://example.com/images/349.jpg
Last edited by ruud (2007-06-05 10:59:15)
Offline
Re: [textile] absolute vs relative url generating
Yes there are several disadvantages:
- can’t load content (like an image) in an external context, like a xml feed.
- can be Google-ghosted, in a worse case scenario.
- can’t be used when the html page is saved out of context, like a File/Save basic action.
- there’s some debate about the spidering of relative links.
- and I’m sure I forgot about some.
However, a tool to mass update thing in the database, like former URL (but that could be used for pretty much anything else) would be quite nice. And it goes alongside a Textilize-batch utility (to apply massively new version of Textile to old articles).
On the other hand, anyone can generate relative URL and such if he wants to. URL generation by vanilla Textpattern is already very un-usable, so it’s not much more work (if any).
Last edited by Jeremie (2007-06-05 11:25:10)
Offline
#4 2007-06-05 11:45:46
- minusf
- Member
- Registered: 2005-02-15
- Posts: 104
Re: [textile] absolute vs relative url generating
thanks for the answers.
first of all, this would be optional…
Jeremie:
- what is google ghosting? :)
- file/save handles relative images just fine as far as i know, it’s even better
-what is spidering relative links? :)
ruud:
i also didn’t know about the permalink issue, but i don’t see any
problems with that frankly. if the image in the permalinked article
becomes ../../images/1.jpg
i’d say that’s a bug.
making the path absolte (without the url) is still no good.
i had a site http://www.example.com/txp/article and i couldn’t
loose the /txp/ part… don’t ask :)
and you couldn’t make more txp install on one domain…
we is experts™
Offline
Re: [textile] absolute vs relative url generating
if the permalinked page is at http://example.com/section/id/title
, and the image is at http://example.com/images/1.jpg
, then on the permalinked page, the image would need a relative url ../../images/1.jpg
. And that’s the problem really, because you want to use the same URL no matter if the image is displayed on the front page or on the permalinked page.
Last edited by ruud (2007-06-05 11:52:28)
Offline
#6 2007-06-05 11:56:33
- minusf
- Member
- Registered: 2005-02-15
- Posts: 104
Re: [textile] absolute vs relative url generating
doh, my bad. normally i have /title only clean urls, that’s why…
well, as images are normally always in one directory, rewrite
rules come handy :)
but yes, obviously this kills the cat.
we is experts™
Offline
Re: [textile] absolute vs relative url generating
Going slightly at a tangent, but I had problems with ../../images/1.jpg. I could not publish an article with this relative path because of mod_rewrite. Apparently hackers commonly use similar sorts of paths so there’s a mod_rewrite rule (on Textdrive). I had to use an absolute path to be able to publish the article.
Offline
Re: [textile] absolute vs relative url generating
An additional motivation for something like what Jeremie describes — the mass update option — is the case where you’ve developed a txp site in a temporary directory to swap into a live site when everything’s good to go.
Or is there a development/production model that txp has incorporated (where the development and production machines are different) that I’ve missed?
Offline
#9 2007-08-23 00:48:29
- Logoleptic
- Plugin Author
- From: Kansas, USA
- Registered: 2004-02-29
- Posts: 482
Re: [textile] absolute vs relative url generating
An additional motivation for something like what Jeremie describes — the mass update option — is the case where you’ve developed a txp site in a temporary directory to swap into a live site when everything’s good to go.
I ran into similar problems when I first started using Textpattern. The trick to to handle images and links to other places in your own site using template tags rather than Textile. While Textile output is saved with the article in the database, template tags are evaluated when the page is rendered. The markup generated by tags like <txp:permlink />
and <txp:image />
is based on the site URL setting under the preferences tab.
For example, say you want to link to one article from within another. You would do this by using <txp:permlink />
and the target article’s ID number:
<txp:permlink id="12" title="My link title">my link text</txp:permlink>
For more advanced linking options, like linking to the front page of a section, use the wet_link plugin. For advanced image display, use upm_image.
If you want to avoid putting your domain name in links and image tags, but don’t want to use template tags, you can use HTML instead of Textile for the link and start the href attribute value with a forward slash. Like this:
Check out my *awesome* <a href="/section-name/article-title">blog post</a>.
Last edited by Logoleptic (2007-08-23 00:57:14)
Offline