Page 1 of 1

Entries per page?

Posted: Sun Feb 15, 2004 7:27 am
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.

Posted: Sun Feb 22, 2004 2:07 pm
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.

Posted: Mon Feb 23, 2004 2:01 am
by techiem2
Thanks!
I'll try that.
Now if I could just remember what I wanted it for....
:)

Posted: Wed Feb 25, 2004 12:05 pm
by flavour
I would use it for a nice statistics box. :D

Does this PHP not work any more?

Posted: Mon May 03, 2004 12:42 pm
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.

Posted: Mon May 03, 2004 1:47 pm
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...

Thanks for the quick reply

Posted: Mon May 03, 2004 1:57 pm
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.

Re: Thanks for the quick reply

Posted: Mon May 03, 2004 2:04 pm
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.

Re: Does this PHP not work any more?

Posted: Tue May 11, 2004 5:00 pm
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.

Posted: Tue May 11, 2004 5:08 pm
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

Posted: Tue May 11, 2004 10:08 pm
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.

Posted: Thu Jun 10, 2004 10:27 am
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.

Posted: Fri Jun 11, 2004 10:21 am
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.

Congatulations to Garvin

Posted: Tue Jul 20, 2004 4:27 am
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:

number of the entries

Posted: Sun Aug 08, 2004 11:36 pm
by apc