Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-11-21 01:30:23

mintyfresh
New Member
Registered: 2006-11-21
Posts: 4

access txp database and functions from outside directory

I’m building a website for a client that will utilize TXP for the “News” portion of the site. Due to what would amount to nested sections in TXP (which isn’t possible), I am not using TXP for the entire site. However, I would like to access the TXP database and functions on the homepage for a sidebar containing the most recent articles.

How can I accompish this?

Offline

#2 2006-11-21 03:39:50

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: access txp database and functions from outside directory

This is just off the top of my head (might have missed something). Assuming that your Txp install was in a directory named “news”:

<?php

	require_once('news/textpattern/config.php');

	if (@ini_get('register_globals'))
	{
		foreach ($_REQUEST as $name => $value)
		{
			unset($$name);
		}
	}

	define('txpath', $txpcfg['txpath']);
	define('txpinterface', 'public');

	require_once(txpath.'/lib/constants.php');
	require_once(txpath.'/lib/txplib_db.php');
	require_once(txpath.'/lib/txplib_misc.php');
	require_once(txpath.'/lib/txplib_html.php');
	require_once(txpath.'/publish/taghandlers.php');

	$prefs = get_prefs();

	$atts = array(
		'sort'		 => 'Posted desc',
		'limit'		 => 10,

		'no_widow' => $prefs['title_no_widow'],

		'label'		 => 'Recent Articles',
		'labeltag' => '',

		'break'		 => br,
		'wraptag'	 => '',
		'class'		 => 'recent_articles',
	);

	echo recent_articles($atts);

?>

Last edited by Mary (2006-12-30 06:15:32)

Offline

#3 2006-12-29 09:41:34

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

Re: access txp database and functions from outside directory

Mary,
A very interesting example. I tested it but I got this terrific error :

Warning: Cannot modify header information – headers already sent by (output started at C:\xampplite\htdocs\txp\test.php:33) in C:\xampplite\htdocs\txp\textpattern\lib\txplib_db.php on line 468

Could you tell me what append and how to correct this error?
Cheers,


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#4 2006-12-29 12:24:00

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: access txp database and functions from outside directory

see FAQ… or enable output buffering.

Last edited by ruud (2006-12-29 12:24:43)

Offline

#5 2006-12-29 15:37:10

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

Re: access txp database and functions from outside directory

Tks ruud! You provide good advices as always!
… A (very) stupid question. Shame on me :o
How to enable output buffering?


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#6 2006-12-30 02:59:44

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: access txp database and functions from outside directory

Please see the PHP manual.


Alex

Offline

#7 2006-12-30 06:16:29

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: access txp database and functions from outside directory

No, that’s the problem with doing it off the top of your head. I’ve corrected the code above.

Offline

#8 2006-12-30 08:04:45

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

Re: access txp database and functions from outside directory

Tks for your answers Zem & Mary.

I m going to try your changes…and if that s works : your are the best Mary!!! :)

Regards.


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#9 2006-12-30 08:10:32

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

Re: access txp database and functions from outside directory

Fine!

You are Genius! :)

— Edit :

In this example only recent_articles match.
How is it possible to manipulate TXP’s variables?
Cheers.

Last edited by Pat64 (2006-12-30 14:50:00)


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

#10 2006-12-31 09:13:20

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: access txp database and functions from outside directory

In this example only recent_articles match.
How is it possible to manipulate TXP’s variables?

Can you elaborate on what you’re trying to achieve? I don’t understand what you’re asking.

Offline

Board footer

Powered by FluxBB