Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Embedding Textpattern Libraries?
I’ve been accessing the Textpattern database through AMFPHP with database queries. However, I’d really like to be able to use Textpattern’s library functions, for example:
safe_update, safe_delete, safe_rows, safe_strftime, doSlash, gps, ps, stripSpace, td, safe_strftime
Has anyone successfully embedded any of the lib files?
Offline
Re: Embedding Textpattern Libraries?
Hipocrite wrote:
Has anyone successfully embedded any of the lib files?
Easiest way is just to move that other software’s tables in Textpattern’s database. Then you will be able to use same lib functions with out modifications and can access that db from Textpattern easily.
Last edited by Gocom (2008-11-26 12:10:12)
Offline
Re: Embedding Textpattern Libraries?
Gocom, AMFPHP does not have any db tables, it is a remoting framework. “AMFPHP allows thin client applications built in languages such as Flash, Flex, and AIR to communicate directly with PHP class objects on the server. PHP developers can leverage their PHP experience in server side code development by connecting to data sources such as web-services, databases, and business applications and return that data to the client.” (amfphp.org)
Here is the AMFPHP plugin I want to embed Textpattern in (currently this plugin reads from the TXP database via direct db queries):
http://www.allflashwebsite.com/article/atxi-amfphp-textpattern-integration
I understand that Textpattern discourages developers from embedding Textpattern inside of something else and encourages them to embed things inside of Textpattern instead. However, in this case the second option is not possible.
Offline
Re: Embedding Textpattern Libraries?
It turns out this was much easier to do than I had expected.
Here is txp_embed.php:
<?php
if (!defined('txpath'))
define("txpath", dirname(__FILE__).'/textpattern');
include txpath.'/config.php';
include txpath.'/lib/constants.php';
include txpath.'/lib/txplib_misc.php';
include txpath.'/lib/txplib_db.php';
include txpath.'/lib/txplib_forms.php';
include txpath.'/lib/txplib_html.php';
?>
And here is a quick test (txptest.php):
<?php
include 'txp_embed.php';
echo safe_field("name","txp_image", "id=1");
?>
Offline