Forums / Setup & design / User IP in template.

User IP in template.

Author Message

Sander van den Akker

Friday 17 February 2006 7:27:27 am

I want to display the IP adress of the person currently browsing the site in a page template. How do I do this?

eZ Publish certified developer
http://auth.ez.no/certification/verify/392313

Łukasz Serwatka

Tuesday 21 February 2006 12:15:15 pm

Hi Sander,

You can use this template operator:
http://ez.no/community/contribs/template_plugins/ezservervars

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Sander van den Akker

Tuesday 21 February 2006 12:40:41 pm

wow excellent support, an extension on the fly ;) I could have built this myself but I wondered if there were any preset template variables I didn't know of.

thank you!

eZ Publish certified developer
http://auth.ez.no/certification/verify/392313

john polo

Tuesday 21 February 2006 6:14:07 pm

this returns i as empty

since the operator works as $_SERVER ..i believe there is something wrong in the script..type on foreach and some others..

Łukasz Serwatka

Tuesday 21 February 2006 11:28:11 pm

@Sander: You are welcome ;) One note here, to avoid issues with view cache you will need to disable view cache for your template and use {cache-blocks} if you will not do it this all your users will see only one IP, as long as you clear view cache.

{set-block scope=root variable=cache_ttl}0{/set-block}

{def $server_vars=ezservervars()}

{$server_vars['REMOTE_ADDR']}

{cache-block}
//rest of your tpl code
{/cache-block}

@John: Works fine here. Do you have any errors? Did you clear the cache?
Have you tried this code in your template?

{def $server_vars=ezservervars()} 
 
{$server_vars|attribute( show,1 )}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

john polo

Wednesday 22 February 2006 5:41:44 am

Lukasz thanks for the answer,

see its not giving out any error nor nothing on the page..i cleared the page i put the blocks up..nothing appears..dunno why

Łukasz Serwatka

Wednesday 22 February 2006 5:47:33 am

@John: Did you enable the extension in admin interface? Which eZ publish version do you use?

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

john polo

Wednesday 22 February 2006 5:51:35 am

yes extension is enabled and ticked.. i am using version 3.7.2

Łukasz Serwatka

Wednesday 22 February 2006 6:07:33 am

Follow this steps:

1. put ezservers dir in ezpublish/extension
2. enable extension in Setup->Extensions
3. Clear all cache
4. put in pagelayout

{def $server_vars=ezservervars()}

{$server_vars['REMOTE_ADDR']}

5. Check your page.

Works fine on eZ publish 3.7.2. Are you sure that you followed all steps correctly?

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

john polo

Wednesday 22 February 2006 6:18:02 am

yes sir everything in order..i can give you my site on email or something if u want to take a look at it

john polo

Wednesday 22 February 2006 11:55:24 am

I fixed the problem with Siw's help..thank you guys..nice job Lukasz

eZ debug

Timing: Jan 18 2025 16:11:41
Script start
Timing: Jan 18 2025 16:11:41
Module start 'content'
Timing: Jan 18 2025 16:11:42
Module end 'content'
Timing: Jan 18 2025 16:11:42
Script end

Main resources:

Total runtime0.7747 sec
Peak memory usage4,096.0000 KB
Database Queries220

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0102 594.4609180.8438
Module start 'content' 0.01020.6418 775.3047675.0234
Module end 'content' 0.65210.1226 1,450.3281344.4609
Script end 0.7747  1,794.7891 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00450.5824210.0002
Check MTime0.00170.2256210.0001
Mysql Total
Database connection0.00080.107510.0008
Mysqli_queries0.690989.17672200.0031
Looping result0.00210.27422180.0000
Template Total0.745096.220.3725
Template load0.00190.243520.0009
Template processing0.743195.914220.3715
Template load and register function0.00010.012110.0001
states
state_id_array0.00110.140610.0011
state_identifier_array0.00070.086820.0003
Override
Cache load0.00160.2121470.0000
Sytem overhead
Fetch class attribute can translate value0.00150.189140.0004
Fetch class attribute name0.00180.2290130.0001
XML
Image XML parsing0.00150.198640.0004
class_abstraction
Instantiating content class attribute0.00000.0031170.0000
General
dbfile0.00190.2511360.0001
String conversion0.00000.001030.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
11content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 38
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs