Page 1 of 1

Some problems with my plugin

Posted: Mon Oct 23, 2006 7:52 pm
by Krzyzak
Hi. I`m stating to write my first plugin- currently, I`m studying http://s9y.org/43.html that document, and looking on staticpages plugin. My problem is -howto write engine, that display me some content in ACP- curently, i`ve got something like this

Code: Select all

 function event_hook($event, &$bag, &$eventData, $addData = null) {
        global $serendipity;

        $hooks = &$bag->get('event_hooks');

        if (isset($hooks[$event])) {
            switch ($event) {

    case 'backend_sidebar_entries':
                    echo '<li><a href="?serendipity[adminModule]=event_display&serendipity[adminAction]=newsletter">' . PLUGIN_NEWSLETTER_ADMIN . '</a></li>';
                    break;
    case 'backend_sidebar_entries_event_display_newsletter':
                    $this->showBackend();

                    break;

  
}
}
}
function showBackend(){
  global $serendipity;
  $spcat = !empty($serendipity['GET']['action']) ? $serendipity['GET']['action'] : $serendipity['POST']['action'];
        switch($spcat) {
    case 'something':
    echo 'it works';
    break;
    case 'other':
    default:
   echo 'it works, too :)';
   break;
    
}
}
but http://localhost/seren/serendipity_admi ... newsletter that link (and any other) didn`t output any effect :/
Could someone help me?

Re: Some problems with my plugin

Posted: Mon Oct 23, 2006 8:14 pm
by garvinhicking
Hi!

Your code basically looks in order. Did you think about registering the listed event hooks in the introspect() method of your plugin? $propbag->add('event_hooks')?

Only those listed in that variabel can be executed.

HTH,
Garvin

Posted: Mon Oct 30, 2006 6:02 pm
by Krzyzak
I can`t repair it- hehe is complete source link
Could someone help me?

Posted: Mon Oct 30, 2006 10:21 pm
by garvinhicking
Hi!

Try this:

http://rafb.net/paste/results/m2KWPs17.html

And please try to insert proper code line indenting if you want to later share the plugin *g*

Best regards,
Garvin

Posted: Wed Nov 01, 2006 4:16 pm
by Krzyzak
Not Found
The requested document was not found on this server.

Web Server at rafb.net
could You paste it again?

Posted: Wed Nov 01, 2006 6:41 pm
by Krzyzak
ok, I`ve solve that. Problem was in

Code: Select all

$propbag->add('event_hooks',
I`d to add

Code: Select all

 'backend_sidebar_entries_event_display_newsletter' =>true, 
But now I`ve got other problem.
I`ve got other problem- I`ve got

Code: Select all

function SampleFunction(){
$foo='bar';
return $foo;
}
and if I paste to my code

Code: Select all

<input type="text" name="title" value="<?php SampleFunction(); ?>" />
it don`t works :/ why?

Posted: Wed Nov 01, 2006 6:45 pm
by garvinhicking
Hi!

All I changed was this:

Code: Select all

        $propbag->add('event_hooks', array(
            'backend_sidebar_entries'                           => true,
            'something' => true,
        ));
into this:

Code: Select all

        $propbag->add('event_hooks', array(
            'backend_sidebar_entries'                           => true,
            'something' => true,
            'backend_sidebar_entries_event_display_newsletter' => true
        ));
(like I also mentioned in my much earlier posting *ggg*)

Regards,
Garvin
Krzyzak wrote:
Not Found
The requested document was not found on this server.

Web Server at rafb.net
could You paste it again?