问题描述
背景:
过去 5 年,我一直在博客平台上运营一个网站.我正在使用将站点托管在我自己的服务器上的选项,通过 FTP 发布.我的服务器正在运行 ColdFusion,所以我决定利用它.我创建了提供附加功能的 Coldfusion 自定义标签,并将这些标签包含在许多可能的帖子中 - 明确地说,是我帖子的 body.Google 决定关闭对这个 FTP 发布选项的访问.我以这个消息为借口转向了 WordPress.现在我必须弄清楚如何处理我帖子中的所有这些 ColdFusion 标签.
I have been running a site on the blogger platform for the past 5 years. I was using the option of hosting the site on my own server, publishing via FTP. My server is running ColdFusion, so I decided to take advantage of that. I created Coldfusion custom tags that provided additional functionality and included those in many of may posts -- to be clear, the body of my posts. Google decided to shut off access to this FTP publishing option. I took that news as an excuse to move to WordPress. Now I have to figure out what to do about all of those ColdFusion tags in my posts.
问题:
我不想失去嵌入到帖子中的自定义标签所提供的功能.我的主要问题是使用自定义标签向 PHP 站点添加功能的最佳方式是什么?我最初的计划是尝试解析页面以查找标签,然后编写一个 PHP 类来基本上模仿 Coldfusion 文件提供的功能.我对 PHP 了解不多,所以我不确定有哪些工具或库可以促进这一点.或者,如果这只是一个愚蠢的想法.这些不是格式良好的 XML 文件,所以我需要一些相当健壮的东西.
I'd like to not loose the functionality provided by the custom tags I have embedded into my posts. My primary question is what's the best way to add functionality to a PHP site using custom tags? My initial plan was to try parsing the page to find the tags, then write a PHP class to basically mimic the functionality that was provided by the Coldfusion file. I don't know much about PHP, so I'm not sure what tools or libraries are out there to facilitate that. Or if it's just a foolish idea. These are not well formed XML files, so I need something fairly robust.
示例:
我使用以下标签:
<cf_taglinks>Tag1, Tag2, Tag3</cf_taglinks>
生成一系列 <a..>Tag#</a>
元素链接到 technorati 或我决定的任何内容(因此拥有自定义标签的好处 - 非常容易改变行为).这个问题的解决方案真的可以处理任何链接,所以如果我有一个 <stackoverflowLink post="3944091"/>
标签,我应该能够将它翻译成
to generate a series of <a..>Tag#</a>
elements that link to technorati or whatever I decide (thus the benefit of having a custom tag - very easy to change behaviors). The solution for this problem could really be able to handle any link, so if I have a <stackoverflowLink post="3944091"/>
tag, I should be able to translate that into
<a href="http://stackoverflow.com/posts/3944091/"
target="_blank">Stackoverflow Question: 3944091</a>
推荐答案
现在我倾向于 自定义标签库在这篇文章中提到a> 作为答案.最好的功能之一是支持隐藏或嵌套标签,如下面的代码块:
Right now I'm leaning towards the Custom Tags library mentioned in this post as the answer. One of the best features is support for buried or nested tags like the code block below:
<ct:upper type="all">
This text is transformed by the custom tag.<br />
Using the default example all the characters should be made into uppercase characters.<br />
Try changing the type attribute to 'ucwords' or 'ucfirst'.<br />
<br />
<ct:lower>
<strong>ct:lower</strong><br />
THIS IS LOWERCASE TEXT TRANSFORMED BY THE ct:lower CUSTOM TAG even though it's inside the ct:upper tag.<br />
<BR />
</ct:lower>
</ct:upper>
我强烈建议下载 zip 文件并查看其中包含的示例.
I highly recommend downloading the zip file and looking through the examples it contains.
这篇关于在 PHP 中解析 CFML 标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!