Jump to content

Phrase error while loading tpl file form hook


ChrisTERiS

Recommended Posts

Hello,

I'm using this code to load a template from within a hook:

$my_template_code = file_get_contents('mytemplate.tpl');

Works fine as for design, but it does not output any phrase.

eg This:

<input type="submit" class="btn btn-info btn-block" value="{$LANG.affiliatesactivate}" />

appears as this in output:

image.png.827a4e28f482bd2c710a8672c5b64e03.png

Any idea what's going wrong? If I add the template code inside the hook, like this:

<input type="submit" class="btn btn-info btn-block" value="'.Lang::trans('affiliatesactivate').'" />

works, but I don't like to have code and design in a php file.

 

Thank you

Chris

Link to comment
Share on other sites

With file_get_contents() you get the content of a file "as is". It doesn't magically parse variables. You'll need to parse them manually with str_replace.

Anyway I don't see why you need to use file_get_content(). If you really want to follow this path, maybe a better option is Smarty fetch. It allows you to return template output instead of displaying it.

Link to comment
Share on other sites

4 minutes ago, Kian said:

If you really want to follow this path, maybe a better option is Smarty fetch. It allows you to return template output instead of displaying it.

I think that with a single answer you solved 2 of my problems. Need to test it. Have another post where I was wondering why $smarty->fetch() does not works. But I was trying with $ca->fetch()

Thank you !

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated