NetTalk Central

Author Topic: Change template port number  (Read 3255 times)

HPabon

  • Newbie
  • *
  • Posts: 20
    • View Profile
    • Email
Change template port number
« on: January 12, 2015, 10:29:17 AM »
Hi,

Is there a way to change on the fly, the port number assigned in the NT template?

I want to read the listening port from a file instead of assigning it in the template.

TIA

Hector

Poul Jensen

  • Full Member
  • ***
  • Posts: 191
    • View Profile
    • Email
Re: Change template port number
« Reply #1 on: January 12, 2015, 01:45:39 PM »
Hi Hector,

To read the portnumber from an inifile:

In WebServer Procedure

    ! Start of "NetTalk Object Before Init Section"
    PortNum# = getini('KundeProg', 'Port', '88', clip(path()) & '\KundeProg.ini' )
    do CheckOmittedWeb
    If Net:ShortInit
        s_web &= pServer
    Else
        s_web &= ThisWebServer
        s_web.SuppressErrorMsg = 1         ! No Object Generated Error Messages ! Generated by NetTalk Extension
        s_web.init()
        s_web.Port = PortNum#
        0{prop:text} = clip(0{prop:text}) & ' | Port:' & s_web.Port & ' |Inifil: ' & clip(GLO:Inifil) & ' | '
        s_web.Open()
        Get(s_web._SitesQueue,1)
    End
       
    OMIT('***HERTIL***')   


And

   ! Start of "NetTalk Object After s_web assigned"
     ***HERTIL***

Cheers,
/Poul

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Change template port number
« Reply #2 on: January 12, 2015, 08:33:55 PM »
Poul is close, but misses a trick.

The setting in the template is an expression, so instead of 88 or 80 you can just use a variable. Say
loc:port

Then in the embed code you just load loc:port from an ini file or xml file or whatever. Usually I put the field on a "settnigs" tab as well.

See the MultiSite Host app for an example of this.

Cheers
Bruce