Page 1 of 1

fetchEntries on external page, mysql Error

Posted: Sun Feb 11, 2007 2:16 pm
by sorar
Hi,

i tried to show the latest entries in an external page (this external is build on an smarty framework).

i inserted this code:

Code: Select all

{php}
// 1: Switch to the Serendipity path
chdir('/usr/local/apache2/htdocs/admin/*****/****/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,
  $serendipity['fetchLimit']);

// 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('..');
{/php}
so now when i load the page i get this error:

Code: Select all

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'httpd'@'localhost' (using password: NO) in /usr/local/apache2/htdocs/admin/*****/****/blog/include/db/mysql.inc.php on line 263
serendipity error: unable to connect to database - exiting.
i am confused because normally the s9y should open the db with my definied blogdb user.
The blog works really fine (so db acces works).

Garvin just told me that it could be that i did not loaded the s9y framework corecctly.


Maybe someone could help?

Thanks in advance

Re: fetchEntries on external page, mysql Error

Posted: Mon Feb 12, 2007 1:38 pm
by garvinhicking
Hi!

Using this PHP code inside Smarty will not work! You must use the PHP code from a PHP file directly, not from within a smarty template.

Best regards,
Garvin

Posted: Mon Feb 12, 2007 5:21 pm
by sorar
Hi,

thanks for your reply. I got it working right now (the entries are showing), i just required the blogview.php file in my index.php from the "external" site. There i assigned a new variable within i saved the printed entries (with ob_start ...). So now i am able to print out the variable in my blog.tpl.

But i got a new issue. The links for the printed entries are not pointing to blog.mydomain.com, they are pointing to externalpage.mydomain.com/archives/blabla. So they are shown but not readable. Is there a possibility to get this fixed? I disabled the "Auto Detect HTTP Host" Option but this did not solve the problem.

Or is there another better mor elegant way to include my entries on this external page (i thought about including the RSS feed but this will end up in senseless traffic)?

Thanks in advance
Sebastian

Posted: Tue Feb 13, 2007 9:36 am
by garvinhicking
Hi!

The links you get should be formatted using the configured $serendipity['baseURL'] directives that you entered in the s9y configuration. Is that not what you want?

Best regards,
Garvin

Posted: Tue Feb 13, 2007 10:32 am
by sorar
hi,

thanks for the help. I got my baseUrl setting on the correct domain (blog.mydoamin.com) but the links to those entries are still (externalpage.com/archives/bla).

I am confused.

Regards,
Sebastian

Posted: Tue Feb 13, 2007 10:43 am
by garvinhicking
Hi!

Ah. It might then be that the links are relative. If you look inside the HTML, do you see relative URLs there?

If so, you need to make them absolute by inserting {$serendipityBaseURL} into your entries.tpl at the places where the links occur.

Best regards,
Garvin

Posted: Tue Feb 13, 2007 10:51 am
by sorar
Hi,

oh that sounds like the solution. I'll try this at home (i think this will fix it because all links occur relatove, as you described above).

Thanks
Regards,
Sebastian