Last post by author to embed externally
-
- Regular
- Posts: 70
- Joined: Fri Feb 23, 2007 6:13 pm
- Location: Freiburg/Germany
- Contact:
Last post by author to embed externally
Hi!
I'm looking for a smart way to display the last post by author from a s9y installation (domain a) on my personal homepage (domain b), same DB server for both.
It would also be nice to have a way to show the last comment by author in the same configuration.
Is there a solution with RSS or similar?
Thanks for any hints or code snippets
Achim
I'm looking for a smart way to display the last post by author from a s9y installation (domain a) on my personal homepage (domain b), same DB server for both.
It would also be nice to have a way to show the last comment by author in the same configuration.
Is there a solution with RSS or similar?
Thanks for any hints or code snippets
Achim
www.ms-reporter.de
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Last post by author to embed externally
Hi!
Two ways, the API way:
(More info: http://www.s9y.org/78.html#A7)
And the DB way:
Printing comments would work in a similar way, you would need to query serendipity_comments for that.
Regards,
Garvin
Two ways, the API way:
Code: Select all
<?php
chdir('/path/to/serendipity');
include 'serendipity_config.inc.php';
$serendipity['GET']['viewAuthor'] = 7; // Enter author id!
$entries = serendipity_fetchEntries(null, null, true); // Pass the parameter for limit=1, I'm too lazy to look it up - it's documented in include/functions_entries.inc.php in the function header
serendipity_printEntries($entries);
And the DB way:
Code: Select all
$sql = mysql_query("SELECT * FROM serendipity_entries WHERE authorid = 7 ORDER BY timestamp DESC LIMIT 1");
$entry = mysql_fetch_array($sql, MYSQL_ASSOC);
print_r($entry);
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
- Regular
- Posts: 70
- Joined: Fri Feb 23, 2007 6:13 pm
- Location: Freiburg/Germany
- Contact:
Re: Last post by author to embed externally
Hi!
Thanks for your answer!
I tried this one:
and I get an error message:
Fatal error: Call to a member function assign() on a non-object in /path/to/s9y/include/functions_entries.inc.php on line 923
I'm lost with this message. What's going wrong here?
Regards,
Achim
Thanks for your answer!
I tried this one:
with a blank test file containing;garvinhicking wrote:the API way
Code: Select all
<?php
chdir('/path/to/s9y/');
include 'serendipity_config.inc.php';
$serendipity['GET']['viewAuthor'] = 3;
$entries = serendipity_fetchEntries(null, true,1);
serendipity_printEntries($entries);
chdir('/path/to/test-file/');
?>
Fatal error: Call to a member function assign() on a non-object in /path/to/s9y/include/functions_entries.inc.php on line 923
I'm lost with this message. What's going wrong here?
Regards,
Achim
www.ms-reporter.de
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Last post by author to embed externally
Hi!
Sorry; after the viewAuthor variable, insert another line "serendipity_smarty_init();".
Regards,
Garvin
Sorry; after the viewAuthor variable, insert another line "serendipity_smarty_init();".
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
-
- Regular
- Posts: 70
- Joined: Fri Feb 23, 2007 6:13 pm
- Location: Freiburg/Germany
- Contact:
Re: Last post by author to embed externally
OK, thanks: I modified my code to
The output is nothing -- a .php file containing only this results in an empty page.
Additionally, if I put it together with only one character (or other html), I get an error:
Warning: Cannot modify header information - headers already sent by (output started at /path/to/test-file/new.php:1) in /path/to/s9y/include/functions_config.inc.php on line 700
What's going on?
Lost in code,
Achim
Code: Select all
<?php
chdir('/path/to/s9y/');
include 'serendipity_config.inc.php';
$serendipity['GET']['viewAuthor'] = 3;
serendipity_smarty_init();
$entries = serendipity_fetchEntries(null, true,1);
serendipity_printEntries($entries);
chdir('/path/to/test-file/');
?>
Additionally, if I put it together with only one character (or other html), I get an error:
Warning: Cannot modify header information - headers already sent by (output started at /path/to/test-file/new.php:1) in /path/to/s9y/include/functions_config.inc.php on line 700
What's going on?
Lost in code,
Achim
www.ms-reporter.de
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Re: Last post by author to embed externally
Try with
If you really want to use Smarty you will need a template file like the docu said:
.... but this is quite complicated to just display some title and a truncated body somewhere else, so I would go the second way via SELECT.
Code: Select all
<html>
<head>
<title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php
chdir('./serendipity/');
include 'serendipity_config.inc.php';
$serendipity['GET']['viewAuthor'] = 1;
$entries = serendipity_fetchEntries(null, true,1);
$author_post = serendipity_printEntries($entries, 0,false,'','return',false,false,false);
echo '<pre>';print_r($author_post);echo '</pre>';
chdir('../');
?>
</body>
</html>
Code: Select all
<?php
// 1: Switch to the Serendipity path. We need to use chdir so that the s9y framework can use its relative calls.
chdir('/home/www/public_html/blog/');
// 2: Start the Serendipity API
include 'serendipity_config.inc.php';
// 3: Start Smarty templating
serendipity_smarty_init();
// 4: Get the latest entries
$entries = serendipity_fetchEntries(null, true,1);
// 5: Put all the variables into Smarty
serendipity_printEntries($entries);
// 6: Get the template file
$tpl = serendipity_getTemplateFile('entries.tpl', 'serendipityPath');
// 7: Format and output the entries
$serendipity['smarty']->display($tpl);
// 8: Go back to where you came from
chdir('/home/www/public_html/');
?>
Regards,
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
-
- Regular
- Posts: 70
- Joined: Fri Feb 23, 2007 6:13 pm
- Location: Freiburg/Germany
- Contact:
Re: Last post by author to embed externally
Both ways are working now ... thank you very much for your support!
www.ms-reporter.de
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
-
- Regular
- Posts: 70
- Joined: Fri Feb 23, 2007 6:13 pm
- Location: Freiburg/Germany
- Contact:
Re: Last post by author to embed externally
Hi!
that's me again ... with an additional question regarding character encodings. While I fetch the most recent entry with
and print it with the output doesn't show mutated vowels (ä, ö, ü, ß)
Example: Drei sch�ne Websites mit sinnvollem CSS3
That's not beautiful, I'm sure there's a switch to deal with that issue?
Thanks in advance and regards,
Achim
that's me again ... with an additional question regarding character encodings. While I fetch the most recent entry with
Code: Select all
mysql_query("SELECT * FROM serendipity_entries WHERE authorid = 3 ORDER BY timestamp DESC LIMIT 1");
Code: Select all
<?php echo( $entry["title"] ); ?>
Example: Drei sch�ne Websites mit sinnvollem CSS3
That's not beautiful, I'm sure there's a switch to deal with that issue?
Thanks in advance and regards,
Achim
www.ms-reporter.de
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Re: Last post by author to embed externally
Tell the browser to read the output file as UTF-8.
Look at my first examples <meta...> head part.
If this isn't possible, while the output page is using latin elsewhere, you should convert your database read with either before the SELECT, or use PHP to convert from UTF-8 to ISO-8859-15 (which is better than utf8_decode($data))
Look at my first examples <meta...> head part.
If this isn't possible, while the output page is using latin elsewhere, you should convert your database read with either
Code: Select all
mysql_query("SET NAMES utf8");
Code: Select all
iconv("UTF-8", "CP1252", $data)
Regards,
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
-
- Regular
- Posts: 70
- Joined: Fri Feb 23, 2007 6:13 pm
- Location: Freiburg/Germany
- Contact:
Re: Last post by author to embed externally
This has been set.Timbalu wrote:Tell the browser to read the output file as UTF-8.
Look at my first examples <meta...> head part.
To summarize:Timbalu wrote:If this isn't possible, while the output page is using latin elsewhere, you should convert your database read with eitherbefore the SELECTCode: Select all
mysql_query("SET NAMES utf8");
Code: Select all
<?php
mysql_query("SET NAMES 'UTF8'");
$sql = mysql_query("SELECT * FROM serendipity_entries WHERE authorid = 3 ORDER BY timestamp DESC LIMIT 1");
$entry = mysql_fetch_array($sql, MYSQL_ASSOC); ?>
<p><?php echo( date( "d. M. Y", $entry["timestamp"] ) ); ?></p>
<a href="http://schnellze.it/?p=<?php echo( $entry["id"] ); ?>"><?php echo( $entry["title"] ); ?>
I'm asking myself why I'm still getting exactly one result when setting the
Code: Select all
LIMIT 2
Regards,
Achim
www.ms-reporter.de
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Pharma-unabhängige Infos für Multiple Sklerose-Betroffene
schnellze.it
Einzigartiges Zusammenspiel aus Popfetcher und s9y
Re: Last post by author to embed externally
That looks like a mysql fetch issue, but possibly isn't, as further on you don't loop the array fetched by mysql. Try to write like this
Code: Select all
$entries = mysql_fetch_array($sql, MYSQL_ASSOC);
foreach ($entries AS $entry) { ?>
<p><?php echo( date( "d. M. Y", $entry["timestamp"] ) ); ?></p>
<a href="http://schnellze.it/?p=<?php echo( $entry["id"] ); ?>"><?php echo( $entry["title"] ); ?><hr />
<?php } ?>
Regards,
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Ian
Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian