getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
632 stars 94 forks source link

Returning Response in shortcode "could not be converted to string" #53

Closed tricki closed 9 years ago

tricki commented 9 years ago

I created a shortcode tied to a controller method where I return a Herbert\Framework\Response object using the view function but I got an error saying it "could not be converted to string". My solution to the problem was adding a __toString() method to the Response class which returns the body but this is just a temporary.

Is this a bug or am I doing something wrong? Should I open a pull request for the __toString() method.

jasonagnew commented 9 years ago

Sorry about that, run composer update and it should be working.

David-Kurniawan commented 8 years ago

Hi @jasonagnew i am newbie in wp plugin development...

i try for creating shortcode using Argument Names , eg: [showMe keyword=foo bar] but in view, i just get foo, not foo bar. how i can showing foo bar as string not array ?

This my code :

// shortcodes.php

$shortcode->add(
    'showMe',
    'myAppApi::showMeVal',
    [
        'keyword' => 'keyword'
    ]
);

and my api like this:

// api.php

$api->add('showMeVal', function($keyword) {
    return (new ShortcodeController)->showmeact($keyword);
});

Thanks so much for the great framework :)

jeremyzahner commented 8 years ago

@David-Kurniawan I guess @arippberger already answered your question in #122.