1

I have a mustache template and the output via php is:

<a href="{{link}}"><img src="{{image}}" title="{{name}}" alt="{{name}}"></a>

but Joomla renders my output to:

<a href="/{{link}}"><img src="/{{image}}" title="{{name}}" alt="{{name}}"></a>

so all links are filled with mustache are wrong.

How can I disable this?

UPDATE: I found that /plugins/system/sef/sef.php up to line 118 are made this change.
But how can I change it without change anything in the core files?

  • Hi Lovntola! I feel the information given in your question is very little and vague. Is this a custom template? Have you done everything needed for the implementation? Is it only for the {{links}}? Also when you say Joomla renders your output like "/{{link} you mean it does render it like this, or the {{inBrankets}} part is outputting the actual content of the variable? *PS I don't have any recent real experience with mustache though... – FFrewin Jan 28 at 19:57
  • Sorry for my bad description. I check the php output und it is href="{{link}}" but the source code in the browser shows href="\{{link}}". This is before mustache starts to work. It is the pure source code without any mustache impact. – Lovntola Jan 28 at 20:06
  • Shorter: It is the same if you write <a href="">test</a> in the source code of a article. The output in the source code is: <a href="/">test</a> – Lovntola Jan 28 at 20:09
  • 1
    Hmm Ok - this comes from the core system SEF plugin. Why is it a problem? What finally happens to your links? – FFrewin Jan 28 at 21:31
  • @FFrewin Sorry I'am not familar with writing plugin for SYSTEM. Can I write a system plugin what change this setting back ( like regex /{{ to {{ ), or is this a bad idea for further updates? – Lovntola Jan 28 at 21:46
2

The Problem is the SEF Plugin. So I don't want to modify a core Plugin, so I wrote a new Plugin that makes the changes only for the mustache template back.
!!! Importent that the new plugin must execute after the SEF Plugin
Here is my code sample to replace the / for the {{name}}

public function onAfterRender()
    {
        if (!$this->app->isClient('site'))
        {
            return;
        }

        $buffer = $this->app->getBody();
        $buffer = str_replace('/{{', '{{', $buffer);
            $this->app->setBody($buffer);
    }
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.