New: Learn Statamic on Laracasts!

We've retired the forum in favor of GitHub Discussions.

New conversations can be started on GitHub. Existing conversations will remain for a while longer.

Head over to GitHub →

Site Helper Tag value is rendered above it's position in the template

Max Glass July 20, 2019 by Max Glass

Here I go again...

I created a site helper tag which works basically. The PHP code in it outputs a variable, let's say $output. This output should be displayed. In the template the tag, let's call it {{ site:output }}, is pasted beneath a H5 heading. But the output by the tag gets rendered above this H5 (but inside the body although it's beneath it in the template.

My Tags.php:


namespace Statamic\SiteHelpers;

use Statamic\Extend\Tags as AbstractTags;

class Tags extends AbstractTags
     * The {{ site:example }} tag
     * @return mixed
    public function output()
          echo 'This is the output.';

My template:

{{ site:output }} <!-- Outputs: "This is the output" -->

The output:

This is the output.


I don't really know why this is.

Answered by Erin Dalzell!
>>>>>>> Answered <<<<<<<
4 Replies