编码 url 不编码
我正在 Moveable Type 中的模板中工作,并希望执行以下操作:
<a href="http://twitter.com/share?url=<$mt:EntryPermalink encode_url="1" $>">Twitter</a>
一切正常,但我担心当前链接或在某些时候即使我使用标题 mt 标签,它可能不适合浏览器地址栏。我认为您可以使用encode_url =“1”,但它似乎没有对我的标题或链接进行编码。例如:我的标题中包含空格,而生成的代码中仍然包含空格。另外对于上面的例子,http:// 不应该以特殊的方式编码吗?因为它不这样做。
我在这里做错了什么吗?
I am working in a template in Moveable Type and would like to do the following:
<a href="http://twitter.com/share?url=<$mt:EntryPermalink encode_url="1" gt;">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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚检查了此代码,它对我来说正常输出。我正在使用MT 4.34。我在索引模板中使用了以下模板代码:
我得到了以下输出:
所以我确认您正在使用支持此修饰符的当前版本的 MT(4.34 或 5.x),因为空格和特殊字符绝对应该被HTML实体所取代。我还会尝试上面提供的代码,以查看您是否获得相同的输出(除非您的永久链接显然会不同)。
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:
And I got the following output:
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).