Templating problems

Found a bug? Tell us!!
serendipity_low
Regular
Posts: 8
Joined: Wed Sep 24, 2003 3:01 am

Templating problems

Post by serendipity_low »

With the new install ... I couldn't get my templates to work ... I noticed that there wasn't any path to the css style sheet. So I edited the layout.php in templates/default/ to put this :

Code: Select all

<html>
    <head>
                <title><?php echo SERENDIPITY_ADMIN_SUITE; ?></title>
                                    <link rel="stylesheet" type="text/css" href="<?php echo (isset($serendipity['serendipityHTTPPath']) ? $ser
endipity['serend
                                    ipityHTTPPath'] : ''); ?>serendipity.css.php" />
                                                        <?php
                                                                            if (isset($serendipity['extCSS']) && strtolower($serendipity['extC
SS']) != 'none') {
                                                                                                ?>
                                                                                                                            <link rel="stylesh
eet" type="text/css" href="<?php echo $serendipity['extCSS']; ?>" />
                                                                                                                                              
          <?php
                                                                                                                                              
                                            }
                                                                                                                                              
                                                                        ?>
                                                                                                                                              
                                                                                                        </head>
Before the mainpane ... and it worked.

Plus ...

the line

Code: Select all

<?php
/* Find any plugins for the RHS */
if (!$serendipity['embed']) {
serendipity_plugin_api::generate_plugins('right', 'td');
}
?>
seems to have caused the default template not to work ( plugins not showing ). I commented out the embed line like so ...

Code: Select all

<?php
/* Find any plugins for the RHS */
//if (!$serendipity['embed']) {
serendipity_plugin_api::generate_plugins('right', 'td');
// }
?>
and it worked fine. Are these really bugs or did i do something i wasn't supposed to during the install ? :?
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

could you provide a patch? diff -u ?

It's hard to understand what the problem is :)
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
serendipity_low
Regular
Posts: 8
Joined: Wed Sep 24, 2003 3:01 am

Post by serendipity_low »

Code: Select all

--- layout.php  2003-08-09 07:18:48.000000000 +0800
+++ layout_2.php        2003-09-29 09:29:06.000000000 +0800
@@ -25,12 +25,29 @@
 ?>
 </div>

+<html>
+    <head>
+                <title><?php echo SERENDIPITY_ADMIN_SUITE; ?></title>
+                                   <link rel="stylesheet" type="text/css" href=
"<?php echo (isset($serendipity['serendipityHTTPPath']) ? $serendipity['serend
+                                   ipityHTTPPath'] : ''); ?>serendipity.css.php
" />
+                                                       <?php
+                                                                           if (
isset($serendipity['extCSS']) && strtolower($serendipity['extCSS']) != 'none') {
+
                ?>
+
                                            <link rel="stylesheet" type="text/cs
s" href="<?php echo $serendipity['extCSS']; ?>" />
+
                                                                        <?php
+

                    }
+

                                                ?>
+


</head>
+



+


                                <body>
+



+
 <table id="mainpane">
     <tr>
 <?php
-if (!$serendipity['embed']) {
-    serendipity_plugin_api::generate_plugins('left', 'td');
-}
+//if (!$serendipity['embed']) {
+serendipity_plugin_api::generate_plugins('left', 'td');
+//}
 ?>
         <td id="content" valign="top">
 <?php
@@ -80,9 +97,11 @@
         </td>
 <?php
 /* Find any plugins for the RHS */
-if (!$serendipity['embed']) {
-    serendipity_plugin_api::generate_plugins('right', 'td');
-}
+//if (!$serendipity['embed']) {
+serendipity_plugin_api::generate_plugins('right', 'td');
+// }
 ?>
     </tr>
 </table>
+</body>
+</html>
:
This diff was taken against a layout.php in the original ../templates/default/layout.php and my modified one.

Is this what you asked for ? 8)
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

Are you using the latest CVS?
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
serendipity_low
Regular
Posts: 8
Joined: Wed Sep 24, 2003 3:01 am

Post by serendipity_low »

2 days old.
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

Your problem is most likely in serendipity_genpage.inc.php instead

since that it where the CSS styles are set.. try turning 'embed' off


Try and run the upgrade file: http://cvs.sourceforge.net/viewcvs.py/p ... &view=auto
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
serendipity_low
Regular
Posts: 8
Joined: Wed Sep 24, 2003 3:01 am

Post by serendipity_low »

I ran the upgrade at : http://cvs.sourceforge.net/viewcvs.py/p ... &view=auto ... but then it didn't work, all the template still did not show the css style sheet. Then I open up my serendipity_genpage.inc.php on my editor and I changed the the line with :

if (!$serendipity['embed'])

to

if ($serendipity['embed']=='false')

so now my serendipity_genpage.inc.php looks like this :

Code: Select all

<?php # $Id: serendipity_genpage.inc.php,v 1.16 2003/08/19 16:06:57 tomsommer Exp $
if ($serendipity['embed']=='false'){
    // serendipity is embedded into an existing structure. No need to output headers then.
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
<html> 
<head>
    <title><?php echo htmlentities($serendipity['blogTitle']); ?></title>
    <meta name="Powered-By" content="Serendipity v.<?php echo $serendipity['version'] ?>">
    <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.css.php" />
    <link rel="alternate"  type="application/rss+xml" title="RSS" href="<?php echo $serendipity['baseURL']; ?>feeds/index.rss" />
    <script language="Javascript" type="text/javascript" src="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.js"></script>
<?php
        if (strtolower($serendipity['extCSS'])!='none') {
?>
    <style type="text/css">@import "<?php echo $serendipity['extCSS']; ?>";</style>
<?php
        }
?>
</head>

<body>
<?php
} // end if (is serendipity embedded?)

include_once('serendipity_config.inc.php');
include_once('serendipity_plugin_api.php');
include_once('serendipity_sidebar_items.php');

if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.
php')) {
    include $serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.php'
;
} else {
    include $serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default/layout.php';
}

if ($serendipity['embed']=='false') {
?>
</body>
</html>
<?php
}
/* vim: set sts=4 ts=4 expandtab : */
?>
Please excuse the ugly way I solved this, I don't really code in php .. maybe I did something wrong .. but I was working on the assumption that the code under the condition '!$seredipity['embed']' is only executed when the variable 'embed' is not set, but then on the database side after running the upgrade script the 'embed' variable is set to 'false' and is still set, so this would mean that the code under '!$serendipity['embed']' still would not be able to run.

This is just a hack and it works on my blog now, I guess a better solution would be used ...

A 'diff -u' would be :

Code: Select all

@@ -1,5 +1,5 @@
 <?php # $Id: serendipity_genpage.inc.php,v 1.16 2003/08/19 16:06:57 tomsommer Exp $
-if (!$serendipity['embed']) {
+if ($serendipity['embed']=='false') {
     // serendipity is embedded into an existing structure. No need to output headers then.
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
@@ -34,7 +34,7 @@
     include $serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default/layout.php';
 }
 
-if (!$serendipity['embed']) {
+if ($serendipity['embed']=='false') {
 ?>
 </body>
 </html>



Please feel free to correct me if I am wrong ... :)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

serendipity_low wrote: Then I open up my serendipity_genpage.inc.php on my editor and I changed the the line with :

if (!$serendipity['embed'])

to

if ($serendipity['embed']=='false')
[...]
This is just a hack and it works on my blog now, I guess a better solution would be used ...
[...]
Please feel free to correct me if I am wrong ... :)
Thanks, I was not aware of this problem. I just checked in a better version into CVS, could you please test this on your setup? Thanks!

Garvin.
serendipity_low
Regular
Posts: 8
Joined: Wed Sep 24, 2003 3:01 am

Post by serendipity_low »

Ummm where can i find this new version ... I checked the cvs on the s9y.org page's cvs address in sf.net and i only see the old version :?:
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

serendipity_low wrote:Ummm where can i find this new version ... I checked the cvs on the s9y.org page's cvs address in sf.net and i only see the old version :?:
Ugh, you're right. I always forget that Sourecforge's CVS is lagging approx. 24 hours behind.

So here's a diff for you:

Code: Select all

Index: layout.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/templates/default/layout.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- layout.php	8 Aug 2003 23:18:47 -0000	1.9
+++ layout.php	1 Oct 2003 09:29:03 -0000	1.10
@@ -28,7 +28,7 @@
 <table id="mainpane">
     <tr>
 <?php
-if (!$serendipity['embed']) {
+if (!$serendipity['embed'] || $serendipity['embed'] == 'false' || $serendipity['embed'] === false) {
     serendipity_plugin_api::generate_plugins('left', 'td');
 }
 ?>
@@ -80,7 +80,7 @@
         </td>
 <?php
 /* Find any plugins for the RHS */
-if (!$serendipity['embed']) {
+if (!$serendipity['embed'] || $serendipity['embed'] == 'false' || $serendipity['embed'] === false) {
     serendipity_plugin_api::generate_plugins('right', 'td');
 }
 ?>

Index: INSTALL
===================================================================
RCS file: /cvsroot/php-blog/serendipity/INSTALL,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- INSTALL	9 Sep 2003 20:13:21 -0000	1.6
+++ INSTALL	1 Oct 2003 09:29:02 -0000	1.7
@@ -70,6 +70,79 @@
    HTML header and includes layout.php
 
 ###############################################################################
+
+###############################################################################
+# THE 'embed' CONFIGURATION DIRECTIVE                                         #
+###############################################################################
+
+In your serendipity configuration, you can set an 'embed' option to true or false.
+
+This defines, whether you use your blog as a standalone webpage - or if you have
+different content wrapped around your blog, like the menu of your usual homepage.
+
+By setting the 'embed' option to true, you have to make sure the following things to
+get everything to work well:
+
+1. 'indexFile' option.
+
+   This configuration option needs to be set to the wrapper file you want to use.
+   Let's say you normally have a 'content.php' file for your webpage. This
+   'content.php' file sets up your internal templates, your menu structure and such.
+   Now you want this file to be used to include your weblog. A simple content.php
+   could look like this:
+   
+   <?php
+   $homepage = new Template_Class;
+   $homepage->set_template($_REQUEST['page']);
+   $homepage->output_header();
+   $homepage->output_content();
+   $homepage->output_footer();
+   $homepage->track_statistics();
+   ?>
+   
+   So normally your file would be called with 'content.php?page=about' to display your
+   'about' page of your personal homepage.
+   
+   Now we want this file to be displayed, having the 'page' variable being set to 'blog'.
+   
+   For this, we set up a 'wrapper.php' file:
+   
+   <?php
+   $_REQUEST['page'] = 'blog';
+   // Let serendipity generate our content:
+   ob_start();
+   require 'index.php';
+   $blog_data = ob_get_contents();
+   ob_end_clean();
+   
+   // Now we include our normal content building file.
+   // This one has to make use of your $blog_data variable to print
+   // the content where appropriate!
+   require 'content.php';
+   ?>
+   
+   You would then set your 'indexFile' serendipity-option to the 'wrapper.php' file.
+   
+  2. Plugin panes & HTML-headers
+  
+   With the example above, we only get the main blog data printed. One of the most visible
+   actions when using the 'embed' option is that the plugin panes are not generated.
+   And HTML headers/foooters are also not provided by s9y in this case, as this should be done
+   by your 'content.php' file.
+   
+   So you have to include them in your 'content.php' file, to have them visible in your
+   embedded setup.
+   
+   You can use this snippet:
+   <?php 
+   serendipity_plugin_api::generate_plugins('left','div');
+   serendipity_plugin_api::generate_plugins('right','div');
+   ?>
+   somewhere in your 'content.php' file.
+  
+The 'embed' option is therefore only recommended to be used by advanced users going for a most flexible setup!
+
+###############################################################################
 Serendipity Weblog - http://s9y.org
 
 Licensed under the BSD License

Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- NEWS	30 Sep 2003 21:40:15 -0000	1.29
+++ NEWS	1 Oct 2003 09:29:02 -0000	1.30
@@ -2,6 +2,7 @@
 
 Version 0.3 (October 1, 2003)
 ------------------------------------
+    * Fixed evaluation of the 'embed' variable and added a small 'HowTo' to the INSTALL file (garvinhicking)
     * Fixed links to images now containing absolute URI to maintain RSS-feed validity. Relative URIs are not allowed/visible within RSS feeds. (garvinhicking)
     * Fixed problem with escaping single quotes during installation (tomsommer)
     * Fixed problem with dual-trailing slashes in paths during installation (tomsommer)

Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- serendipity_config.inc.php	30 Sep 2003 21:22:00 -0000	1.34
+++ serendipity_config.inc.php	1 Oct 2003 09:29:02 -0000	1.35
@@ -72,7 +72,7 @@
  */
 include($serendipity['serendipityPath'] .'serendipity_lang.inc.php');
 
-if ($serendipity['embed']) {
+if ($serendipity['embed'] && ($serendipity['embed'] == 'true' || $serendipity['embed'] === true)) {
     $serendipity['baseURL'] = 'http://' . $_SERVER['HTTP_HOST'] . $serendipity['serendipityHTTPPath'];
 }
 

Index: serendipity_config_local.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config_local.tpl,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- serendipity_config_local.tpl	30 Sep 2003 20:17:07 -0000	1.18
+++ serendipity_config_local.tpl	1 Oct 2003 09:29:02 -0000	1.19
@@ -36,7 +36,7 @@
 $serendipity['extCSS']               = '{External Stylesheet|extCSS|string|none}';          // You can define a stylesheet uri here, aditionally to the settings adjustable in the admin interface (enter 'none' if you don't need this)
 $serendipity['wysiwyg']              = '{Use WYSIWYG editor|wysiwyg|bool|0}';               // Do you want to use the WYSIWYG editor (CAUTION: only turn this on if you use Microsoft's Internet Explorer!!!)?
 $serendipity['XHTML11']              = '{Force XHTML 1.1 compliance|XHTML11|bool|0}';       // Do you want to force XHTML 1.1 compliance (may cause problems for back-/frontend on older 4th generation browsers)
-$serendipity['embed']                = '{Is serendipity embedded?|embed|bool|0}';           // If you want to embed serendipity within a regular page, set to true to discard any headers and just print the contents. You can make use of the indexFile option to use a wrapper class where you put your normal webpage headers.
+$serendipity['embed']                = '{Is serendipity embedded?|embed|bool|0}';           // If you want to embed serendipity within a regular page, set to true to discard any headers and just print the contents. You can make use of the indexFile option to use a wrapper class where you put your normal webpage headers. See the INSTALL file for more information!
 $serendipity['track_exits']          = '{Track exit URLs|track_exits|bool|1}';                              // Do you want to track exit targets?
 $serendipity['blockReferer']         = '{Blocked Referers|blockReferer|string|;}';                          // Are there any special hosts you want not to show up in the referers list? Separate the list of hostnames with ';' and note that the host is blocked by substring matches!
 

Index: serendipity_genpage.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_genpage.inc.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- serendipity_genpage.inc.php	19 Aug 2003 16:06:57 -0000	1.16
+++ serendipity_genpage.inc.php	1 Oct 2003 09:29:03 -0000	1.17
@@ -1,5 +1,5 @@
 <?php # $Id$
-if (!$serendipity['embed']) {
+if (!$serendipity['embed'] || $serendipity['embed'] == 'false' || $serendipity['embed'] === false) {
     // serendipity is embedded into an existing structure. No need to output headers then.
 ?>
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
@@ -34,7 +34,7 @@
     include $serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default/layout.php';
 }
 
-if (!$serendipity['embed']) {
+if (!$serendipity['embed'] || $serendipity['embed'] == 'false' || $serendipity['embed'] === false) {
 ?>
 </body>
 </html>
Guest

Post by Guest »

Warning: file("/home/teacentral/www/blog/templates/templates/info.txt") - No such file or directory in /home/teacentral/www/blog/serendipity_functions.inc.php on line 62

That happens when default is chosen with the newest and the style.css is still not being read
Guest

Post by Guest »

ignore the comment before the last regarding the file not found, i was just being stupid ...

but style.css is still not being read ...
Guest

Post by Guest »

Changing the line in serendipity_genpage.inc.php from :

Code: Select all

 <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.css.php" />
to

Code: Select all

 <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['baseURL']; ?>serendipity.css" />
works ... I don't really know why ... :?
tomsommer
Core Developer
Posts: 240
Joined: Tue Sep 02, 2003 6:43 pm
Location: Denmark
Contact:

Post by tomsommer »

You might have the wrong httppath then, check your paths on the config page
Tom Sommer (Serendipity Core Developer)
http://blog.dreamcoder.dk
Guest

Post by Guest »

I am really at my wits end ... the http path is correct. :cry: The thing is ... the stylesheet works from admin ... it just doesn't work from the user side ...
Post Reply