1 2015-09-10 14:00:29 (edited by devmount 2015-09-10 14:01:37)

Topic: Plugin output in content pages always on top

Hey all,

to get to know monstra, i coded a small plugin just du check functionalities. Now I have the problem, that the output my plugin produces is always on top of the content section of pages, when i put the plugin shortcode into content pages, and not on its proper position where i put it in the content page. e.g:

content page:

<h1>My heading</h1>
{myplugin return="some string"}

will result in:

some string
My heading

So the order changed and my plugin output is on top of the heading. Can't figure out the reason... can sb help me?

_Andreas

PS: from what I saw yet: monstra is awesome!

Re: Plugin output in content pages always on top

My problem is still unsolved... after over 200 views, nobody has an idea?
Merry christmas @all!

_Andreas

3 2016-01-18 21:34:05

Re: Plugin output in content pages always on top

Hi devmount

Sorry that no one has helped you.

I think the problem could be how you are pushing the output. I could be completely wrong with this.

For example when you use create your class with your shortcode function.

    Shortcode::add('myplugin', 'myplugin::_shortcode');
    class myplugin {
        public static function _shortcode($attributes) {
            return $attributes['return'];
        }
    }

you should be returning what you want to be displayed rather then echo command.

I'm not sure if you have figured this out yet but let me know if this has helped you.

Re: Plugin output in content pages always on top

Hi gambi,

thanks, that was exactly the problem. I pushed the content like this:

View::factory('myplugin/views/frontend/index')
    ->assign('some', $variable)
    ->display();

But the display function echos the rendered content... so instead I returned the rendered content:

return View::factory('myplugin/views/frontend/index')
    ->assign('some', $variable)
    ->render();

Now the plugin output is correctly inserted into the page content.
Thanks!

_Andreas