Problems with embedded Layout

Having trouble installing serendipity?
Post Reply
tiberian
Posts: 4
Joined: Thu Jan 27, 2005 9:51 am
Location: Germany, Oelde

Problems with embedded Layout

Post by tiberian »

Hi out there!

I want to use the serendipity blog on my website. But i have several Problems with making it work in my Homepage. I am using an own written CMS (using Smarty as well) called viá index.php?fetchId=3

The Blog is in the subfolder blog/
Now have a look @ my index.php

Code: Select all

<?php          //blog loader
   if($_GET['fetchId'] == 3) {
      ob_start();
      chdir ("blog/");
      require 'index.php';
      chdir ("../");
      $blog_data = ob_get_contents();
      
      ob_end_clean();
      }

      chdir('../clancore3');
      require_once ( 'libs/class.mysql.php' );
      require_once ( 'class.cms.php' );
      require_once ( 'libs/config.inc.php' );
      chdir('../tiberiandesign');
      
      $db = new db($sql['host'],$sql['user'],$sql['password'],$sql['name']);
      $cms = new ClanCoreCMS($db);
      
      $cms->assign('cmsMenu',$cms->fetchMenu());
      $cms->assign("blog", $blog_data);
      $cms->display('index.top2.tpl');
            
      if(isset($_GET['fetchId']))
         $cms->fetchSite($_GET['fetchId']);
      else 
         $cms->fetchHome();
      
      $cms->display('index.bottom.tpl');   
 ?>
That works fine as described in your readme. Now when i click on an articel or comment or what ever the URL changes into blog/archives/1-Neue-Webseite-online.html (in example)
On this site of course there is no templates loaded.
What have I to do, having my Layout on all Blog sites?

thanks for your help and sorry for my bad english
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Problems with embedded Layout

Post by garvinhicking »

You should go the "wrapper" way.

1. Create a file blog/wrapper.php:

Code: Select all

<?php
$_GET['fetchId'] = 3;
chdir('..');
require 'index.php';
?>
2. Enter Serendipity Configuration. Set "indexFile" directive to "wrapper.php". If you use mod_rewrite, you'll need to edit your .htaccess file and change the occasions of 'index.php' to 'wrapper.php'

Now if a url like blog/archives/1-entry.html is called, Serendipity will not call the 'index.php' file, but instead the 'wrapper.php'. That one will set the variables required to your CMS (fetchId) and include it's index file. That again will then include Serendipity's index.php again and create the appropriate output.

Have fun,
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/
tiberian
Posts: 4
Joined: Thu Jan 27, 2005 9:51 am
Location: Germany, Oelde

Re: Problems with embedded Layout

Post by tiberian »

garvinhicking wrote:You should go the "wrapper" way....
I thought, I did ;)
I missunderstood the wrapper way a little bit, but now I got the blog in my Layout. Thanks for that. But now I get the following error
Warning: main() [function.include]: Failed opening '' for inclusion (include_path='/www/htdocs/tiberiandesign/serendipity/:/www/htdocs/tiberiandesign/serendipity/bundled-libs/:.:/opt/lampp/lib/php') in /www/htdocs/tiberiandesign/serendipity/serendipity_genpage.inc.php on line 43
What to do?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Problems with embedded Layout

Post by garvinhicking »

Hi!

The error message you're getting is because Serendipity can't find the 'layout.php' file anywhere. That usually means that when Serendipity executes, it's not inside its core directory.

Check that all chdir() calls are properly alligned so that when Serendipity's index.php executes, it's in the right directory...

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/
tiberian
Posts: 4
Joined: Thu Jan 27, 2005 9:51 am
Location: Germany, Oelde

Post by tiberian »

I am really sorry but I don´t get it.
I checked all chdirs (via getcwd)

Code: Select all

 echo getcwd();
include_once(serendipity_getTemplateFile('layout.php', 'serendipityPath'));
That´s all right. It outputs the serendipity root dir (blog/)

What is about the config? Do I have to set baseURL to http://mydomain.tld/blog (where the blog lies) or http://mydomain.tld (where the blog is included from?) or what´s about serendipityHTTPPath?

Looking at the otputted sourcecode I recognized another problem - maybe they relate to each other. The compiled html sourcecode looks like this
-> my own TemplateHeader (correct)

-> serendipitys Header (not correct - it shouldn´t output a header when it´s in 'embedded' mode should it?)

-> seredipity´s Content (correct - in my case the errormsg)

-> my own TemplateFooter (correct)
<edit> The outputted header is (I set 'use XHTML 1.1' to true !!!)

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <meta name="Powered-By" content="Serendipity v.0.7.1" />
    <link rel="stylesheet" type="text/css" href="serendipity.css.php" />
    <link rel="alternate"  type="application/rss+xml" title="RSS" href="index.php?/feeds/index.rss2" />
    <link rel="alternate"  type="application/x.atom+xml"  title="Atom"  href="index.php?/feeds/atom.xml" />

</head>
PS: now I recognized, that you are from germany as well - if you like to we could write in german?! just an idea

Thanks for your patience and help
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Okay, using your code I think the problem is a wrong setting of serendipityHTTPPath and baseURL. Both need to point to the serendipity directory, not your core root directory. This is needed because with a wrong HTTPPath setting Serendipity may not find the right layout file.

About the HTML code: The header of Serendipity should not be emitted in embedded mode. The header only includes everything until <body> - everything after that will be shown in embedded mode - so if you mean "banner" with "header", then that will be shown in embedded mode.

If you don't want that, you need to edit your templates layout.php file to uncomment the banner.

I'd like to write in english here, so that some others may benefit from your problem? You seem to be getting along well in english, so if you don't mind, I'd like to continue this way :)

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