Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-11-26 07:04:10

Hipocrite
Member
From: New Orleans, La
Registered: 2007-11-07
Posts: 17
Website

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

#2 2008-11-26 12:09:32

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

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

#3 2008-11-26 17:08:37

Hipocrite
Member
From: New Orleans, La
Registered: 2007-11-07
Posts: 17
Website

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

#4 2008-11-27 04:24:55

Hipocrite
Member
From: New Orleans, La
Registered: 2007-11-07
Posts: 17
Website

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

Board footer

Powered by FluxBB