Entries per page?

Having trouble installing serendipity?
Post Reply
techiem2
Regular
Posts: 35
Joined: Sun Feb 15, 2004 6:59 am
Contact:

Entries per page?

Post by techiem2 »

Ok. I spent the evening figuring out how to get Serendipity integrated into my site.
https://techiem2.no-ip.com
Most things seem to be working.
I can't get comments working right, but I'll mess with that later.
They're not all that important at the moment since the forum is there.
But would be nice to make work.
But First, how do I define how many entries show up on the main page?
Also, is there a way to use php code in the html snippet plugin?
If not, that would be a cool feature to consider for future releases.
Thanks.
flavour
Regular
Posts: 14
Joined: Mon Feb 02, 2004 12:11 pm

Post by flavour »

Garvin made a small php box plugin.
Here's how to build it:

(1) Create a folder named "serendipity_plugin_php" in the plugins directory.
(2) In that directory create a file named "serendipity_plugin_php.php"
(3) Here is the content of that file:

Code: Select all

<?php # $Id: serendipity_plugin_php.php,v 1.0 2004/01/23 09:51:51 garvinhicking Exp $

/* PHP code plugin by Garvin Hicking (www.supergarv.de). Executes any PHP code */

class serendipity_plugin_php extends serendipity_plugin {
    function introspect(&$propbag)
    {
        $propbag->add('name',          'PHP Plugin');
        $propbag->add('description',   'Führt PHP-Code aus');
        $propbag->add('configuration', array(
                                        'title',
                                        'content'
                                       )
        );
    }

    function introspect_config_item($name, &$propbag)
    {
        switch($name) {
            case 'title':
                $propbag->add('type',        'string');
                $propbag->add('name',        'Titel');
                $propbag->add('description', 'Titel des PHP-Blocks');
                break;

            case 'content':
                $propbag->add('type',        'html');
                $propbag->add('name',        'PHP-Code');
                $propbag->add('description', 'Der auszuführende PHP-Code');
                break;
            
            default:
                return false;
        }
        return true;
    }

    function generate_content(&$title, $output = true)
    {
        $title = $this->get_config('title', $title);
        if ($output) eval($this->get_config('content'));
    }
}

?> 
Save the file and now you should be able to select that plugin in your admin panel. It's a simple eval-function. So you can execute any php-code.
techiem2
Regular
Posts: 35
Joined: Sun Feb 15, 2004 6:59 am
Contact:

Post by techiem2 »

Thanks!
I'll try that.
Now if I could just remember what I wanted it for....
:)
flavour
Regular
Posts: 14
Joined: Mon Feb 02, 2004 12:11 pm

Post by flavour »

I would use it for a nice statistics box. :D
chief123
Regular
Posts: 5
Joined: Mon May 03, 2004 12:38 pm

Does this PHP not work any more?

Post by chief123 »

I used the "plugin" on this page before and it worked fine. Now with upgrading it doesn't seem to.

Did something change with new fixes or am I doing something wrong on my part?

The error I'm getting is: "Parse error: parse error in /home/XXX/XXX/XXX.com/sy/plugins/serendipity_plugin_php/serendipity_plugin_php.php(41) : eval()'d code on line 1" no matter what I enter and no matter how I do it.

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

Post by garvinhicking »

Maybe you can output (echo) the contents of what should be eval'ed first. Then you should look out for possible parse errors inside of there.

It seems to more to a parse error inside the plugin, rather than the full plugin structure.

As I don't use nor encourage the use of the plugin, I can't say much more yet...
# 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/
chief123
Regular
Posts: 5
Joined: Mon May 03, 2004 12:38 pm

Thanks for the quick reply

Post by chief123 »

Thanks for the quick reply. Since you don't recommend this plugin is there another better way to get PHP output in the sidebars?

Specifically what I'm trying to do is to put an Amazon feed in the side bar but don't want to use Javascript if I can avoid it.

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

Re: Thanks for the quick reply

Post by garvinhicking »

chief123 wrote:Thanks for the quick reply. Since you don't recommend this plugin is there another better way to get PHP output in the sidebars?
Yes, of course there is! That's what plugins are usually meant to - you create a plugin for everything you want, and NOT use a general plugin like the PHP one.

Just take a plugin like plugins/serendipity_plugin_comments and duplicate that to match your needs.

On our wiki at http://www.s9y.org/ there now is also a technical Plugin API documentation and should guide you trough creating one.
Specifically what I'm trying to do is to put an Amazon feed in the side bar but don't want to use Javascript if I can avoid it.
That should really be fairly easy. If you can't get along with the plugin API, just post the PHP code you want to have here and I will write the plugin for you. But I suggest you to try building a plugin yourself first, that increases your abilities to create new plugins next time :)

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/
sol
Regular
Posts: 11
Joined: Sat May 08, 2004 7:03 am
Location: Perth, Australia

Re: Does this PHP not work any more?

Post by sol »

chief123 wrote:I used the "plugin" on this page before and it worked fine. Now with upgrading it doesn't seem to.

Did something change with new fixes or am I doing something wrong on my part?

The error I'm getting is: "Parse error: parse error in /home/XXX/XXX/XXX.com/sy/plugins/serendipity_plugin_php/serendipity_plugin_php.php(41) : eval()'d code on line 1" no matter what I enter and no matter how I do it.

Thanks for any help.
I got the same error when I first used it, then it occured to me that I don't need to enter the "<?php" tags. Just write the statements and it should work fine.
sol
Regular
Posts: 11
Joined: Sat May 08, 2004 7:03 am
Location: Perth, Australia

Post by sol »

garvinhicking wrote: As I don't use nor encourage the use of the plugin, I can't say much more yet...
I just tried this plugin, and I can see how it would be quite useful to me. Is there any reason why you neither you don't "use nor encourage the use of" this plugin? Are there security issues or is it just "better practice" to write one's own plugin?

cheers; sol
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

sol wrote: I just tried this plugin, and I can see how it would be quite useful to me. Is there any reason why you neither you don't "use nor encourage the use of" this plugin? Are there security issues or is it just "better practice" to write one's own plugin?
cheers; sol
It's both of them. As far as security is involved: With this plugin you can of course execute ALL PHP functions available and get all the s9y variables. In a one-user-installation this is allright so far, but as soon as another user (in a multiuser environment for example) enters the area, that plugin can make the whole server insecure.

And there's performance on the other hand: An eval() is really considered no good style and it costs some performance bits; it's all in all better practice to have a small custom plugin to do what your PHP-code should do. It's better portable and you could even share the plugin on our wiki :)

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/
Glyphon
Regular
Posts: 5
Joined: Mon May 03, 2004 6:22 am

Post by Glyphon »

i tried to create this plugin, but i'm having a little difficulty. i followed the steps above exactly, and the plugin is not showing in the drop down box and there is an error message under the drop down box.

did this functionality change with v.0.6-pl2?

here is the error message.
Error: serendipity_plugin_templatedropdown

and here are some screen shots.

Image

and

Image

thanks in advance for any input.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi Glyphon!

Please read through the complete posting list here - the PHP plugin is unmaintained and unrecommended, and thus it can very well be that it doesn't work anymore.

It's really easy to write a specific plugin instead of a generic PHP one. And much more better performing, shareable and maintainable.

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/
apc
Regular
Posts: 7
Joined: Tue Jul 20, 2004 2:38 am
Location: Brasil
Contact:

Congatulations to Garvin

Post by apc »

Congatulations to Garvin because create code:


<?php # $Id: serendipity_plugin_php.php,v 1.0 2004/01/23 09:51:51 garvinhicking Exp $

/* PHP code plugin by Garvin Hicking (www.supergarv.de). Executes any PHP code */
etc...
-------------------------------------------------------------------------------
I put sub_folder CVS. This is important? I hope so.

I hope use for me in my Serendipity. I´m begyning now.

My entries work ok. But I don´t know to use archives (by Quickjump) cliking date days in calendar yet! But I´m happy w/ s9y.


Thanks very mutch.

http://www.hostinganime.com/lerdort/
http://lerdort.servehttp.com/whostingan ... /index.php
http://medhttp.servehttp.com/serendipity/index.php


:oops:
apc
apc
Regular
Posts: 7
Joined: Tue Jul 20, 2004 2:38 am
Location: Brasil
Contact:

number of the entries

Post by apc »

apc
Post Reply