Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-05-10 19:46:54

tmq
New Member
Registered: 2005-09-10
Posts: 9

Excerpting most recent excerpt on external page

I would like to include an the excerpt of my most recent post on a page not generated by textpattern. In other words, I can’t use a txp tag, but will have to call to the MSQL db directly.

I found this example of doing this for Wordpress (How to add 5 full Wordpress posts on an external html page), and wondered if anyone here could help me getting this to work with Textpattern.

For Wordpress, the query is this:

$query = "Select * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY id DESC LIMIT 5";

and the question is what should replace post_type='post', post_status='publish'...

Any help would be greatly appreciated.

Offline

#2 2008-05-10 20:09:01

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Excerpting most recent excerpt on external page

post_status='publish' seems to refer to “status”, publish should be “4” (which is “live”), but what is “post_type” in WP about?

EDIT: can you take a look at the database in phpMyAdmin, and name some entries from the “post_type” column?

Last edited by uli (2008-05-10 20:35:11)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#3 2008-05-10 21:06:21

tmq
New Member
Registered: 2005-09-10
Posts: 9

Re: Excerpting most recent excerpt on external page

I’m not sure. I don’t have a WP db to look at, but I suppose post type is whether it is a ‘post’ or a ‘page’ (WP has this difference between updated posts and static pages). I’d just take out the post type for textpattern, except that I don’t really see then where anything is being called.

I tried this:

$query = "Select * FROM textpattern WHERE post_status='4' ORDER BY id DESC LIMIT 1"; 

but it generates nothing.

Offline

#4 2008-05-10 21:06:39

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

Re: Excerpting most recent excerpt on external page

Ofcourse it doesn’t generate anything. In example your calling madeup column and also you need to use right columns/fields inside the for. In example for that query.

$query = "Select * FROM 'textpattern' WHERE Status = '4' ORDER BY Posted DESC LIMIT 5";
$rs = mysql_query($query);

Also you have to rename the called columns from the for-statement. In example: Excerpt_html, Title etc. For more help, look at /textpattern/include/txp_list.php.

Last edited by Gocom (2008-05-10 21:11:08)

Offline

#5 2008-05-10 21:37:08

tmq
New Member
Registered: 2005-09-10
Posts: 9

Re: Excerpting most recent excerpt on external page

Gocom, your sig describes my experience completely!

My knowledge of php is essentially nil, so I should probably not be trying this at home. Thanks for your response, but I don’t really get it. For example, what ‘for’ do you mean?

Offline

#6 2008-05-10 22:29:50

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Excerpting most recent excerpt on external page

Gocom, tmq wants to make a call to the db that feeds a txp installation. How can looking at a txp-codefile be of any help in this case? Your knowledge may be profund, so leave some more information, please, to get things going. :)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#7 2008-05-10 22:36:38

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

Re: Excerpting most recent excerpt on external page

Coz in txp_list.php there is example about that matter, it’s the backend’s listing page. He needs query, plus a code that outputs the information. The query can be done with that example, but it must be changed to look same as txp_list.php as the db columns are different…

Last edited by Gocom (2008-05-10 22:39:15)

Offline

#8 2008-05-10 23:09:40

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Excerpting most recent excerpt on external page

tqm, in case you don’t understand: your problem is like plug and socket.
Just that your plug has another number of pins than the socket. And Gocom showed us the way to the shelf where the soldering-manual is kept. ;)
The only thing is: the f. manual is encrypted.

Sorry, tqm, here is where my help ends …

Have a nice weekend, though :)

Gocom wrote

He needs query

I bet “he” is a she ;)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#9 2008-05-10 23:42:04

tmq
New Member
Registered: 2005-09-10
Posts: 9

Re: Excerpting most recent excerpt on external page

Actually, ‘he’ is correct. But thanks for your help.

Here’s what I have so far. It doesn’t work, but it feels closer:

<?php

$db_username = 'xxx';
$db_password = 'xxx';
$db_database = 'xxx';

mysql_connect(localhost, $db_username, $db_password);
@mysql_select_db($db_database) or die("Unable to select database");

$query = "Select * FROM 'textpattern' WHERE Section='articles' AND Status='4' ORDER BY 'Posted' DESC LIMIT 1"; 

$query_result = mysql_query($query);
$num = mysql_numrows($query_result);
mysql_close();


$title = mysql_result($query_result, 0, "Title");
$content = mysql_result($query_result, 0, "Excerpt");

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
</head>
<body>
<div id="Id">
<?php echo $title; ?>
<?php echo $content; ?>
</div>
</body>

Last edited by tmq (2008-05-11 00:19:07)

Offline

#10 2008-05-11 00:05:23

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Excerpting most recent excerpt on external page

tmq

for some reason textile blockcode is not working

You simply left out one blank between bc.. and the <


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#11 2008-05-11 00:19:42

tmq
New Member
Registered: 2005-09-10
Posts: 9

Re: Excerpting most recent excerpt on external page

fixed, thanks

Offline

#12 2008-05-11 00:39:37

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: Excerpting most recent excerpt on external page

I personally would like to learn from what you did, where did you change something? Esp. what did the trick Gocom maintained silence on?

Last edited by uli (2008-05-11 00:40:58)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB