fetchEntries on external page, mysql Error

Having trouble installing serendipity?
Post Reply
sorar
Regular
Posts: 12
Joined: Sat Oct 28, 2006 4:41 pm

fetchEntries on external page, mysql Error

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: fetchEntries on external page, mysql Error

Post 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
# 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/
sorar
Regular
Posts: 12
Joined: Sat Oct 28, 2006 4:41 pm

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# 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/
sorar
Regular
Posts: 12
Joined: Sat Oct 28, 2006 4:41 pm

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# 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/
sorar
Regular
Posts: 12
Joined: Sat Oct 28, 2006 4:41 pm

Post 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
Post Reply