Page 1 of 2

different categories to be displayed on different pages

Posted: Sun Oct 30, 2005 2:31 pm
by jorainbo
Hi,

I have a question after the successfull installation of s9y.

So far I have one category which is embedded in my Layout and displayed on a certain page (in this case "News").

Is it possible to create another category which will be displayed on another page (e.g. "latest updates")?

I don´t want the visitor to choose the category or so, I just want to display the entries of each category on a different page.
Or do I have to install s9y again to a different directory to use it on different pages with different entries?

If it is possible to do this, what do I have to change?

My "news.php" looks like this:

Code: Select all

<?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 'newscontent.php';
?>
The newscontent.php contains my Layout and includes the blog with

Code: Select all

<?php echo $blog_data ?> 
Thanks for any help

Jorainbo

Re: different categories to be displayed on different pages

Posted: Sun Oct 30, 2005 2:36 pm
by garvinhicking
You can do that with a single installation

Just modify your code like this:

Code: Select all

<?php
$_REQUEST['page'] = 'blog';
// Set the right category:
$_GET['serendipity']['category'] = 1;
// 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 'newscontent.php';
?>
So with the $_GET['serendipity']['category'] you can set which Category s9y should display. You can create categories in your s9y panel then, and take their IDs to set within your inclusion code.

HTH,
Garvin

Posted: Sun Oct 30, 2005 2:59 pm
by Guest
Thanks for your help, I will try that.

However, I have a problem now. So far I haven´t had a category, now I have created two categories "News" and "Latest updates" in which I want to place my entries.

I can make new entries (at least it says "your entry has been saved") and I have my created categories in the dropdown box of the "new entry" form, but after the creation of these categories, the page "edit entries" in the admin-panel" is blank, just a white screen.

Any ideas?

Thanks again
Jorainbo

Posted: Sun Oct 30, 2005 3:02 pm
by jorainbo
Anonymous wrote:Thanks for your help, I will try that.

However, I have a problem now. So far I haven´t had a category, now I have created two categories "News" and "Latest updates" in which I want to place my entries.

I can make new entries (at least it says "your entry has been saved") and I have my created categories in the dropdown box of the "new entry" form, but after the creation of these categories, the page "edit entries" in the admin-panel" is blank, just a white screen.

Any ideas?

Thanks again
Jorainbo
Please forget this message, it works now...don´t know why it was a white page on the first try...thanks...I will now try to make the changes...

Posted: Sun Oct 30, 2005 3:28 pm
by jorainbo
Hi again,

as soon as I add these two lines:

Code: Select all

// Set the right category:
$_GET['serendipity']['category'] = 1;
to my news.php

I get an

500 Internal Server Error

As soon as I remove them, it works again and all entries will be displayed (no matter which category they are in).

I have checked in the Admin Panel that News is category id=1 and updates is category id=2

Is there a typo or something? Any other changes I need to make?

Thanks again
jorainbo

Posted: Sun Oct 30, 2005 3:36 pm
by garvinhicking
Hm, you shouldn't get a internal server error, that is strange. Do you have access to your apache error logs? Something must be in there to know what causes the error.

Which PHP version are you using?

Regards,
Garvin

Posted: Sun Oct 30, 2005 3:45 pm
by Guest
garvinhicking wrote:Hm, you shouldn't get a internal server error, that is strange. Do you have access to your apache error logs? Something must be in there to know what causes the error.

Which PHP version are you using?

Regards,
Garvin
PHP Version: 5.0.3

You can check it here:

http://www.toto99.com/phpinfo.php

I don´t think I have access to the server log:

here´s the link to thefile that causes the server error:

http://www.toto99.com/blog/news.php

and to the working version:

http://www.toto99.com/blog/news1.php

The only difference between news.php and news1.php are these two lines:

Code: Select all

// Set the right category:
$_GET['serendipity']['category'] = 1;

Posted: Sun Oct 30, 2005 4:13 pm
by garvinhicking
Could you please post the whole news.php file somewhere?

It seems that there is a parse error in your PHP file, and as your PHP is included as a CGI it won't show the error message...

Regards,
Garvin

Posted: Sun Oct 30, 2005 4:23 pm
by jorainbo
news.php (not working)

Code: Select all

<?php
$_REQUEST['page'] = 'blog';
// Set the right category:
$_GET['serendipity']['category'] = 2;
// 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 'newscontent.php';
?>
I was wrong, News is Category ID 2 and updates is Category ID 1, but anyway, I have entries in both categories...

news1.php (working)

Code: Select all

<?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 'newscontent.php';
?>
Anything else I need to post ?

Thanks for your help
Jorainbo

Posted: Sun Oct 30, 2005 4:55 pm
by garvinhicking
That's strange, the PHP code is really alright. :-(

Try to change the added line to:

Code: Select all

$_GET['serendipity'] = array('category' => 2);
If that doesn't work, try this:

Code: Select all

$_GET['test'] = 1;
and see if it creates trouble. It seems to me that your PHP chokes on modifying the $_GET array?!

I'm a bit clueless, I've never heard/seen that before.

Regards
Garvin

Posted: Sun Oct 30, 2005 5:45 pm
by Guest

Code: Select all

$_GET['serendipity'] = array('category' => 2);
produces also an Internal Server error

Code: Select all

$_GET['test'] = 1;
works and displays all entries from all categories.

Does this help?

Thanks
Jorainbo

Posted: Sun Oct 30, 2005 9:34 pm
by garvinhicking
Wow, this is just too weird. Please ask your provider for the full PHP and Apache errorlog. This seems to be specific to your webinstallation, I cannot explain this behaviour and have never seen this in 7 years of developing PHP. :-(

Regards,
Garvin

Posted: Wed Nov 02, 2005 11:31 pm
by jorainbo
garvinhicking wrote:Wow, this is just too weird. Please ask your provider for the full PHP and Apache errorlog. This seems to be specific to your webinstallation, I cannot explain this behaviour and have never seen this in 7 years of developing PHP. :-(

Regards,
Garvin
Hi again,

finally I got access to the server error log. But the only entry in there after trying to access the news.php in the browser is the following:

Premature end of script headers: /www/toto99/cgi-bin/php

Does this help in any way?

Thanks
Jorainbo

Posted: Thu Nov 03, 2005 10:27 am
by garvinhicking
This error message may happen if your PHP script is truncated inproperly. That might happen because of linebreaks or so.

Can you please talk to your provider and ask him why PHP is failing on that file? The admin can launch the PHP cgi binary and test your file with:

Code: Select all

php -l /path/to/your/news.php
and see if it generates parse errors?!

Regards,
Garvin

Posted: Thu Nov 03, 2005 3:44 pm
by Guest
garvinhicking wrote:This error message may happen if your PHP script is truncated inproperly. That might happen because of linebreaks or so.

Can you please talk to your provider and ask him why PHP is failing on that file? The admin can launch the PHP cgi binary and test your file with:

Code: Select all

php -l /path/to/your/news.php
and see if it generates parse errors?!

Regards,
Garvin
okay, I talked to the tech support guy of my provider, I gave him the URL to the news.php file that causes the error and the URL to this thread so that he knew what´s goign on and what we already tried...his
answer was that there are no parse errors. He said the error he's getting is a "premature end of script" error (which I already knew). He checked the full configuration of the PHP and he said everything is configured properly. He also said that these types of errors that we're getting here are usually a problem with the script.

So anyway -- he says it's not server side...anything else I can do?

Thanks
Jorainbo