NetTalk Central

Author Topic: How to put variables in static pages and replace at runtime  (Read 2686 times)

Johan de Klerk

  • Full Member
  • ***
  • Posts: 214
  • Johan de Klerk
    • View Profile
    • Designer Software
Hi,

I have my index page as a static page.

It works great but now I have the need to put variables inside my static index.html page and have them replaced at runtime.

How do I get it working?

Any help would be appreciated.

Regards

Johan de Klerk
Clarion 10, NT 11.57

gsanettalk

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: How to put variables in static pages and replace at runtime
« Reply #1 on: May 25, 2008, 03:01:47 AM »
Hi Johan,

You can use a TAG to display a value from the Session queue.

In your code, you could do something like:

 p_web.SetSessionValue ('MyText', glo:MyText)

Then in your static html page, insert a tag like this:

 <!-- Net:s:MyText ->

and this should display the contents of glo:MyText on the page.

You could also use a TAG placed inside your html page to call a NetWebSource procedure which returns your variable content eg. <!-- Net:MyProc -->

In your code, you then add a NetWebSource procedure called MyProc and you can pretty much spit out any content/data at that location.

For tags to work in static html pages, the first line in your html source page must have the NetTalk webserver tag: <!-- NetWebServer -->

Hope that helps
Regards
Graham
 
Tags

A NetTalk Tag is basically a wrapper around some variable, or procedure, that you want to include at this point in the page.  It takes the form

<!--Net:Something -->

In this case that Something are procedures, so the HTML generated by those procedures are included on the page.

If the Something is not a procedure, then it might be a session variable. For example you might have a session variable and you can include that on the page. You’ll see a lot of this happening as you progress through the examples.

Pages that contain tags have to be parsed by the server. If you hand-code a complete web page, or if you use a static page on the disk these tags can still be used. However in that case the first line of the page must be

<!-- NetWebServer -->

It's important to note that you can put any tag you like into your web page, as long as you handle it in the ProcessTag method in the WebHandler procedure. However there are some built-in Tags which you can use without having to add code ot the WebHandler procedure.

<!-- Net:FunctionName -->
This tag will call the specified function in that point in the code. This can be a function based on any of the NetWeb procedures. (Note: Not all the procedures make sense at every point though. For example embedding Forms needs to be done carefully as Forms require extra setup.)
 

<!-- Net:s:SessionVariable -->
This will embed the current contents of the session variable on the web page. If the variable should be formatted (for example a DATE field) then make sure the Picture parameter of the session variable is set using either
p_web.SetSessionValue('name','value','pic') or
p_web.SetSessionPicture('name','pic')
 

<!-- Net:v:Variable -->
This will display the current contents of a Parameter at this point in the web page. In other words the same as (2) above, but uses the Value queue, not the Session queue.


Johan de Klerk

  • Full Member
  • ***
  • Posts: 214
  • Johan de Klerk
    • View Profile
    • Designer Software
Re: How to put variables in static pages and replace at runtime
« Reply #2 on: May 25, 2008, 06:48:05 AM »
THANK YOU, THANK YOU.  8)

You are the man.

This works 100%, well better than 100%.

Now the playing can start.

I have been battling with this for the past two days without any luck.

I highly appreciate your help on a Sunday.

Regards

Johan de Klerk
Clarion 10, NT 11.57