Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

PHP Code Smarty, Plugin Function

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Adam44
Smarty n00b


Joined: 26 Jan 2015
Posts: 2

PostPosted: Mon Jan 26, 2015 8:48 pm    Post subject: PHP Code Smarty, Plugin Function Reply with quote

Hi there...

I am new here, referred by someone who tried to help me but wasn't able to make this work for me with Smarty.

I use Clicky stats to to monitor site stats, and they have an option to insert a user's username instead of their IP address in the stats. However, since I use Smarty in my members area, the code he made does not work. He said I need a plugin function, or something like that...

Is this something easy to do? Will I need to hire a programmer, or is it a quick fix?

Forgive my ignorance... I have no idea how to accomplish this.

Here is the code he gave me:

Code:

<?php if (isset($_SERVER['PHP_AUTH_USER'])){ ?>
<script type="text/javascript">
  var clicky_custom = clicky_custom || {};
  clicky_custom.visitor = clicky_custom.visitor || {};
  clicky_custom.visitor ["username"] = '" . $_SERVER['PHP_AUTH_USER'] . "';
</script>
<?php } ?>


Thanks in advance for any help you can give me.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Jan 29, 2015 7:24 pm    Post subject: Reply with quote

You can put the following into your templates
Code:
{if isset($smarty.server.PHP_AUTH_USER)}
<script type="text/javascript">
  var clicky_custom = clicky_custom || {ldelim}{rdelim};
  clicky_custom.visitor = clicky_custom.visitor || {ldelim}{rdelim};
  clicky_custom.visitor ["username"] = '{$smarty.server.PHP_AUTH_USER}';
</script>
{/if}


See
http://www.smarty.net/docs/en/language.variables.smarty.tpl
http://www.smarty.net/docs/en/language.function.ldelim.tpl
Back to top
View user's profile Send private message
Adam44
Smarty n00b


Joined: 26 Jan 2015
Posts: 2

PostPosted: Mon Feb 02, 2015 8:17 pm    Post subject: Reply with quote

Just wanted to say thank you! This worked perfectly!
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP