Jump to content

PHP in templates


Gal Lachiany
 Share

Recommended Posts

How use PHP in Templates (for example: gstats)
I tried to make SQL execution and get some info from Database but <php> and {php} are not working.
Let me know how can I use PHP tags and functions inside of your templates.

Thanks You Guys.

Edited by Gal Lachiany
Link to comment
Share on other sites

{{$var = 'something';}}

But you're not supposed to run queries on templates in 4.0. You better extend any file and display the results, like this.

<ips:template parameters="$comment" />
{{$date = \IPS\Member::loggedIn()->GetDateDifference( $comment->author()->joined );}}
<span data-ipsTooltip data-ipsTooltip-label="{lang="ejd_joined"}">
	<li class="ipsType_light{{if \IPS\Settings::i()->ejd_smallfonts}} ipsType_small{{endif}}"><i class="fa fa-sign-in fa-lg"></i> 
		{{if \IPS\Settings::i()->ejd_format == 1}}
			{datetime="$comment->author()->joined"}
		{{else}}
			{$date}
		{{endif}}
	</li>
</span>

On this plugin I exteded the \IPS\Members ( GetDateDifference ).

Link to comment
Share on other sites

On 22.10.2015, 16:17:35, Adriano Faria said:

{{$var = 'something';}}

But you're not supposed to run queries on templates in 4.0. You better extend any file and display the results, like this.


<ips:template parameters="$comment" />
{{$date = \IPS\Member::loggedIn()->GetDateDifference( $comment->author()->joined );}}
<span data-ipsTooltip data-ipsTooltip-label="{lang="ejd_joined"}">
	<li class="ipsType_light{{if \IPS\Settings::i()->ejd_smallfonts}} ipsType_small{{endif}}"><i class="fa fa-sign-in fa-lg"></i> 
		{{if \IPS\Settings::i()->ejd_format == 1}}
			{datetime="$comment->author()->joined"}
		{{else}}
			{$date}
		{{endif}}
	</li>
</span>

On this plugin I exteded the \IPS\Members ( GetDateDifference ).

I have no idea how to do it, you'll make me pay you?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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