Yet another embedding question

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
BlasterCalm
Regular
Posts: 7
Joined: Thu Aug 25, 2005 3:43 pm

Yet another embedding question

Post by BlasterCalm »

First of all, thanks for developping S9y, this is a great blogging software.

I managed to embed it somewhat into one of my web site, see the result here :

http://www.hoe.nicewebs.com/site/?page=nouvelles

However, when you click on "continuer" (which leads to the extended view), you get a fully blank page, which is not good. I have to mention that the web site does not use .css, and I suspect this is the root of the problem. However, can you please direct me in the right direction to have the extended text also in my web design (the web site was not design by myself initially)

The main index page of the web site includes a require like this

Code: Select all

      <?php include('include_centre.php'); ?>
Which itself contains

Code: Select all

if($page != "") {
include('pages/'.$page.'.php');
} else {
include('pages/accueil.php');
}
And then the page is called by the command "?page=nouvelles" and the nouvelles.php file contains

Code: Select all

$_REQUEST['page'] = 'nouvelles';
// Recupération des données du blog en buffer
ob_start();
require 'http://www.hoe.nicewebs.com/news/index.php'; //addrese du blog
$blog_data = ob_get_contents();
ob_end_clean();

//Impression des données du blog

if ($_REQUEST['page'] = 'nouvelles') { 
echo $blog_data; 
}
I have to admit that I'm not a big php programmer and that Smarty looks like an obscure language to me. I've read many posts on these forums but none of them seemed to have the same problem I have now.

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

Re: Yet another embedding question

Post by garvinhicking »

This should be quite easy.

1. Create a file "myindex.php" with this content in your /news/ serendipity directory:

Code: Select all

// Set the page variable
$_REQUEST['page'] = 'nouvelles';

// Go to the path where your /site/index.php is in
chdir($_SERVER['DOCUMENT_ROOT'] . '/site/');

// Include your page framework, it does all the rest.
include index.php;
2. Go to your serendipity configuration, set the "indexFile" option from "index.php" to "myindex.php"

Now, those two steps will make Serendipity point its URLs to myindex.php instead, and this includes your framework which in turn includes the Serendipity Framework again.

I hope you don't find this too obscure. The easier way would be to use smarty templating for your whole project, but I respect that this is also much work!

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/
BlasterCalm
Regular
Posts: 7
Joined: Thu Aug 25, 2005 3:43 pm

Post by BlasterCalm »

Thanks for your quick reply.

No, I dont' find it too obscure, but it is still not working.

So I created a file myindex.php and change the S9y configuration so it takes this file as indexfile

Code: Select all

<?php
// Set the page variable 
$_REQUEST['page'] = 'nouvelles'; 

// Go to the path where your /site/index.php is in 
chdir($_SERVER['DOCUMENT_ROOT'] . '/site/'); 

// Include your page framework, it does all the rest. 
include (index.php);

?>
However, the result I get when I click on the extended text is

Code: Select all

Warning: main(indexphp): failed to open stream: No such file or directory in /var/www/html/news/myindex.php on line 9

Warning: main(): Failed opening 'indexphp' for inclusion (include_path='.:/php/includes:/usr/share/php') in /var/www/html/news/myindex.php on line 9
(error on the include statement

I tried to modify your script into that, and the result is still not the one expected:

Code: Select all

<?php
// Set the page variable 
$_REQUEST['page'] = 'nouvelles'; 

// Go to the path where your /site/index.php is in 
chdir($_SERVER['DOCUMENT_ROOT'] . '/site/'); 

// Include your page framework, it does all the rest. 
include ($_SERVER['DOCUMENT_ROOT'] . '/site/index.php');

?>
Any idea ?

On a side note, this is a test site. In the future, the blog would stay here but the main site is on another server. How would the include work there ?

Thanks -[/quote]
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Please replace the $_SERVER['DOCUMENT_ROOT'] include part so that it points to the right directory. So enter the full path to your /site/ directory there instead.
On a side note, this is a test site. In the future, the blog would stay here but the main site is on another server. How would the include work there ?
Well, this won't work. There's no way to make this happen smoothly - you would get a lot of errors. What you want to do is to use iframes or frames.

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/
BlasterCalm
Regular
Posts: 7
Joined: Thu Aug 25, 2005 3:43 pm

Post by BlasterCalm »

I tried with the full path but I have exactly the same issue. I tried many things, i.e. the full path since the root and then removing one by one one level, it still gives me the same message. Must be very obvious. I guess I'll rest a little on that one and hopefully I'll find the source of the problem.

Edit... Now is my code.. is opens the design but the page is not displayed properly...

Code: Select all

<?php
// Set the page variable 
$_REQUEST['page'] = 'nouvelles'; 

chdir('/var/www/html/site/'); 

// Include your page framework, it does all the rest. 
include ('/var/www/html/site/index.php/');

?>
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Change the code to:

Code: Select all

<?php
// Set the page variable 
$_REQUEST['page'] = $page = 'nouvelles'; 

chdir('/var/www/html/site/'); 

// Include your page framework, it does all the rest. 
include ('/var/www/html/site/index.php/');

?>
This should work; you use $page in your framework instead of $_REQUEST['page'] so the s9y thing wouldn't get parsed.

BTW, you should change your framework to use absolute image paths. So that it prints "/site/images/sous_logo.jpg" instead of "images/sous_logo"; because the URL from /news/ and /site/ are different.

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/
BlasterCalm
Regular
Posts: 7
Joined: Thu Aug 25, 2005 3:43 pm

Post by BlasterCalm »

Thanks, we're almost there -- but still not there--.

I updated the script, changed the paths in my index.php so the full /site/images are taken in account.

However, when clicking on the extended view, first it appears that the news is not extended (still the front page displayed) and then some background missing.... I have no other references to images in my php scripts
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

If you check the HTML output of the body view, you'll see that it outputs all HTML/TITLE content and other stuff.

It seems you turned off the Serendipity "Embed" option?

How do you do your include? It seems the URL is different. As I told you, the whole thing does NOT WORK ON DIFFERENT SERVERS! :-)

It only works on one singular file system. The reason for this is that PHP variables need to be passed from one site to the other site. This cannot be done on two seperate servers.

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/
BlasterCalm
Regular
Posts: 7
Joined: Thu Aug 25, 2005 3:43 pm

Post by BlasterCalm »

Yes I understood that part about two different servers - for the time being it is on the same server. I'll try to find out if we can move the whole site on my server (i.e. where I test it now), so if it works there we can keep it there.

I might have mistakenly disabled the option "embedded" (tried so many things) so I put it back in "embedded" mode. I updated my scripts so now the layout seems ok. Still, it doesn't go to extended mode yet.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Could you please post your current versions of your:

/site/index.php
/news/myindex.php

file, and the snippet of other files that contain the code needed?

Can it be that your framework touches the $_SERVER['REQUEST_URI'] variables? It seems the index.php file from serendipity is not able to recognize which URL it should show.

Could you please edit your Serendipity's "index.php" and search for the following code on top of the page:

Code: Select all

$uri = $_SERVER['REQUEST_URI'];
Change this do:

Code: Select all

$uri = $_SERVER['REQUEST_URI'];
echo "Serendipity match on $uri.<br />Need to match on '" . PAT_ARCHIVES . "' or '" . PAT_COMMENTSUB . "'<br />\n";
This output should give us a clue on why it cannot show the right content!

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/
BlasterCalm
Regular
Posts: 7
Joined: Thu Aug 25, 2005 3:43 pm

Post by BlasterCalm »

site/index.php

Code: Select all

<html>
<head>
<title>Horizon Of Eternity</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- Fireworks MX Dreamweaver MX target.  Created Fri Mar 25 18:17:14 GMT+0100 (Paris, Madrid) 2005-->
</head>
<body bgcolor="#000000">
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <!-- fwtable fwsrc="HoEsite3découpé.png" fwbase="accueil.jpg" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
  <tr>
   <td><img src="/site/images/spacer.gif" width="19" height="1" border="0" alt=""></td>
   <td><img src="/site/images/spacer.gif" width="232" height="1" border="0" alt=""></td>
   <td><img src="/site/images/spacer.gif" width="531" height="1" border="0" alt=""></td>
   <td><img src="/site/images/spacer.gif" width="18" height="1" border="0" alt=""></td>
   <td><img src="/site/images/spacer.gif" width="1" height="1" border="0" alt=""></td>
  </tr>

  <tr>
   <td colspan="4"><img src="/site/images/bordure_haut.jpg" width="800" height="16" border="0" alt=""></td>
   <td><img src="/site/images/spacer.gif" width="1" height="16" border="0" alt=""></td>
  </tr>
  <tr>
    <td rowspan="4" background="/site/images/bordure_gauche.jpg"> </td>
   <td colspan="2"><img src="/site/images/logo.jpg" width="763" height="285" border="0" alt=""></td>
   <td rowspan="2"><img src="/site/images/bordure_haut_droite.jpg" width="18" height="328" border="0" alt=""></td>
   <td><img src="/site/images/spacer.gif" width="1" height="285" border="0" alt=""></td>
  </tr>
  <tr>
   <td><img src="/site/images/sous_logo.jpg" width="232" height="43" border="0" alt=""></td>
    <td><? include('include_titre.php'); ?></td>
   <td><img src="/site/images/spacer.gif" width="1" height="43" border="0" alt=""></td>
  </tr>
  <tr>
    <td valign="top" background="/site/images/fond.jpg"><img src="/site/images/menu.jpg" alt="" width="232" height="429" border="0" usemap="#accueil"></td>
    <td rowspan="2" valign="top" background="/site/images/fond.jpg"> 
      <p> </p>
      <table width="95%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td> <div align="justify">
              <?php include('include_centre.php'); ?>
            </div></td>
        </tr>
      </table>
      <p align="left"> </p>
      </td>
    <td rowspan="2" background="/site/images/bordure_droite.jpg"> </td>
   <td><img src="/site/images/spacer.gif" width="1" height="429" border="0" alt=""></td>
  </tr>
  <tr>
    <td valign="bottom" background="/site/images/fond.jpg"><img src="/site/images/copyright.jpg" alt="" width="232" height="55" border="0"></td>
   <td><img src="/site/images/spacer.gif" width="1" height="55" border="0" alt=""></td>
  </tr>
  <tr>
   <td><img src="/site/images/bordure_gauche_bas.jpg" width="19" height="28" border="0" alt=""></td>
   <td colspan="2"><img src="/site/images/bordure_bas.jpg" width="763" height="28" border="0" alt=""></td>
   <td><img src="/site/images/bordure_droite_bas.jpg" width="18" height="28" border="0" alt=""></td>
   <td><img src="/site/images/spacer.gif" width="1" height="28" border="0" alt=""></td>
  </tr>
</table>
<map name="accueil">
<area shape="rect" alt="" coords="0,158,187,197" href="?page=recrutement">
<area shape="rect" alt="" coords="0,267,186,305" href="http://www.hoe.nicewebs.com/g2/main.php">
<area shape="rect" alt="" coords="0,229,186,267" href="http://pagesperso.laposte.net/mirdhyn2/forum/index.php" target="_blank">
<area shape="rect" alt="" coords="0,197,186,229" href="?page=membres">
<area shape="rect" alt="" coords="2,124,188,158" href="?page=histoires">
<area shape="rect" alt="" coords="2,87,188,123" href="?page=accueil">
<area shape="rect" alt="" coords="0,0,232,429" href="?page=histoires">
</map>
</map>
</body>
</html>
/site/include_centre

Code: Select all

<?

if($page != "") {
include('pages/'.$page.'.php');
} else {
include('pages/accueil.php');
}

?>
/site/include_titre

Code: Select all

<?

if($page=="accueil") {
echo "<img src=\"/site/images/titre_accueil.jpg\">";
} elseif($page=="histoires") {
echo "<img src=\"/site/images/titre_histoires.jpg\">";
} elseif($page=="recrutement") {
echo "<img src=\"/site/images/titre_recrutement.jpg\">";
} elseif($page=="hierarchie") {
echo "<img src=\"/site/images/titre_hierarchie.jpg\">";
} elseif($page=="membres") {
echo "<img src=\"/site/images/titre_membres.jpg\">";
} elseif($page=="histoire_hoe") {
echo "<img src=\"/site/images/titre_histoires.jpg\">";
} elseif($page=="histoire_hoe2") {
echo "<img src=\"/site/images/titre_histoires.jpg\">";
} elseif($page=="histoire_hoe3") {
echo "<img src=\"/site/images/titre_histoires.jpg\">";
} elseif($page=="histoire_hoe4") {
echo "<img src=\"/site/images/titre_histoires.jpg\">";
} else {
echo "<img src=\"/site/images/titre_accueil.jpg\">";
}

?>
/news/myindex.php

Code: Select all

<?php 
// Set the page variable 
$_REQUEST['page'] = $page = 'nouvelles'; 

chdir('/var/www/html/site/'); 

// Include your page framework, it does all the rest. 
include ('/var/www/html/site/index.php/'); 

?>
Updated the serendipity index.php as you requested

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

Post by garvinhicking »

What does your site/pages/nouvelles.php file look like? As this is the one that in turn includes Serendipity's index.php once again!

The problem is, this output is stored on your Serendipity page:

Code: Select all

Serendipity match on /news/index.php.<br />Need to match on '@/archives([/A-Za-z0-9]+)\.html@' or '@/([0-9]+)[_\-][0-9a-z\.\_!;,\+\-]*\.html@i'<br />
[/quote]

So it says "/news/index.php" as the content of $_SERVER['REQUEST_URI']. But instead that should look like "/news/myindex.php?/archives/3-billet.html"!

The issue here is that the variable gets filled with the serendipity URI. That can only happen under this circumstances:

1. Somewhere in your framework/scripts, something changes $_SERVER['REQUEST_URI']

2. You do not use Apache webserver and instead use a server which does not fill $_SERVER['REQUEST_URI'] properly (IIS)

3. Somewhere iny our code/framework you include a file via "include http://blabla/index.php" instead of "include index.php". This will reset the Reuqest URI to that URI instead of keeping the current one.

In your code snippet, try to replace:

[code]
include ('/var/www/html/site/index.php/'); 
with

Code: Select all

include ('/var/www/html/site/index.php'); 
(remove the trailing slash). Maybe this is responsible for the URI change.

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/
BlasterCalm
Regular
Posts: 7
Joined: Thu Aug 25, 2005 3:43 pm

Post by BlasterCalm »

Thanks Garvin,

It seems we cannot find the problem, I'll try to integrate the blog differently.

To answer your suggestions :

1) You've seen all the scripts that are called. There is no other script modifying the variables

2) The server is running Apache Fedora Core 1

3) Same as 1, you have all the scripts that are called here. There are no other "hidden scripts" running on that site

I removed the trailing slash, it doesn't change a thing.

I'll try to integrate the blog differently, I'll hate to use an iframe but that's probably what I am going to do.

Thanks for looking at this.
Post Reply