开发者

encode url not encoding

I am working in a template in Moveable Type and would like to do the following:

<a href="http://twitter.com/share?url=<$mt:EntryPermalin开发者_StackOverflowk encode_url="1" $>">Twitter</a>

It all works but I'm worried that the current link or at some point even if I use a title mt tag that it might not be right for the browser address bar. I thought you could use encode_url="1" but it doesn't appear to encode my titles or links. For example: I have a title with spaces in it and the resulting code still has the spaces in it. Also for the example above shouldn't the http:// be encoded in a special way? Because it doesn't do it.

Am I doing something wrong here?


I just checked this code and it is outputting properly for me. I am using MT 4.34. I used the following template code in an index templated:

<mt:Var name="url" value="http://google.com/hello I have spaces">
<mt:Entries lastn="1">
    Permalink: <mt:EntryPermalink encode_url="1"><br />
    Fake URL: <mt:Var name="url" encode_url="1">
</mt:Entries>

And I got the following output:

Permalink: http%3A%2F%2Fwww.capndesign.com%2Farchives%2F2010%2F09%2Fthe_big_picture_scenes_from_china.php
Fake URL: http%3A%2F%2Fgoogle.com%2Fhello%20I%20have%20spaces

So I would confirm that you're using a current version of MT (4.34 or 5.x) that supports this modifier, because the spaces and special characters should definitely be getting replaced with HTML entities. I'd also try the code I provided above to see if you get the same output (except your permalink will obviously be different).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜