在PHP中解析CFML标记 [英] Parse CFML tags in PHP

查看:128
本文介绍了在PHP中解析CFML标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景

我一直在运行一个网站在博客平台上过去5年。我使用的选项,在我自己的服务器上托管网站,通过FTP发布。我的服务器运行ColdFusion,所以我决定利用它。我创建了Coldfusion自定义标签,提供了额外的功能,并包括许多可能的帖子 - 清楚,我的帖子的正文。 Google决定关闭此FTP发布选项的访问权限。我把这个消息作为借口转移到WordPress。

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,所以我不知道什么工具或图书馆在那里,以促进。或者如果它只是一个愚蠢的想法。

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 ..& ; / 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>


推荐答案

现在我倾向于自定义代码在此帖中提到作为答案。最好的功能之一是支持隐藏或嵌套标签,如下面的代码块:

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标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆