NetTalk Central

Author Topic: dynamically rename url path  (Read 4022 times)

ntnewbies

  • Full Member
  • ***
  • Posts: 184
    • View Profile
    • Email
dynamically rename url path
« on: August 05, 2020, 07:24:36 PM »
hi friends,
i have a procedure called Product.
when i call that procedure, then the url path is localhost/product

i will be using the same procedure for other business option like Services, Consultation and so on (i provide the entry field for the customer to type their own service name).

thus, for example, if the customer select the option as Consultation, then the url should be
localhost/consultation

but since the procedure is Product, thus the url remains localhost/product

how do i achieve it as localhost/consultation

any idea?

jason
nt11.41
c11



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: dynamically rename url path
« Reply #1 on: August 06, 2020, 12:03:23 AM »
It's done in the WebHandler procedure, in the _SendFile method, just after loc:filename is set.

So, for example;
if lower(loc:filename) = 'consultation'
  loc:filename = 'product'
end

(This is from memory, so you may have to experiment a bit - but if you inspect loc:filename then you should see what I mean).

cheers
Bruce

ntnewbies

  • Full Member
  • ***
  • Posts: 184
    • View Profile
    • Email
Re: dynamically rename url path
« Reply #2 on: August 06, 2020, 03:45:23 AM »
hi bruce,

if i use your code, then the url will become locahost/product

but i want it to appear as localhost/consultation


the procedure name is product.

jason

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: dynamically rename url path
« Reply #3 on: August 06, 2020, 08:14:30 PM »
Hi Jason,

As your "Product" function is really designed to perform the work of a "virtual" page, eg Consultation.

Wait until the embed point _SendFile (so any other NetTalk pages are dealt with first). If the page requested doesn't match one of your built in page names, its now the right time to check if a virtual page (one your customer has made up) has been requested.

At this time, check your database (don't bother checking if the page is .jpg, .png, .js, .css otherwise it will unnecessarily slow your system down) to see if the page requested matches one defined by your customers.

If it does, you call product and have it do the work.

Your URL will be what the human typed/followed, so it will already be correct and doesn't need fixing.

Just make sure your builtin names don't clash with arbitrary names your customers are allowed to invent.

Regards
Bill

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: dynamically rename url path
« Reply #4 on: August 10, 2020, 02:36:43 AM »
>> if i use your code, then the url will become locahost/product

not in the browser.

>> but i want it to appear as localhost/consultation

in the browser will appear whatever the user "asked for".

Cheers
Bruce