NetTalk Central

Author Topic: friendly url - how to?  (Read 6390 times)

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 431
    • View Profile
    • Email
friendly url - how to?
« on: July 08, 2019, 04:09:46 AM »
Hi

I think I've read about it somewhere in the documentation a long time ago. But I simply can't remember where?
Can anyone help?

Regards Niels

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: friendly url - how to?
« Reply #1 on: July 09, 2019, 02:30:36 AM »
In WebHandler, ReadFile method, AFTER parent call.
Check the Return value there, and if it's 404 (page not found) then "rewrite" the p_FileName variable.

For example, I have a table "Quicklinks". So my code looks like this;

  If returnValue = 404 ! page not found, so check quicklinks file to see if there's a match
    Access:quickLinks.Open()
    Access:quickLinks.UseFile()
    Qui:Quick = sub(p_FileName,len(clip(self.site.WebFolderPath) & '\')+1,255)
    If Access:QuickLinks.Fetch(Qui:QuickKey) = 0
      Qui:full = clip(self.site.WebFolderPath) & '\' & Qui:Full
      ReturnValue = PARENT.ReadFile(Qui:Full,p_Buffer,p_FileDate,p_FileTime,p_Parse,pShared)
    end 
    Access:quickLinks.Close()
  End

Cheers
Bruce

Niels Larsen

  • Sr. Member
  • ****
  • Posts: 431
    • View Profile
    • Email
Re: friendly url - how to?
« Reply #2 on: July 09, 2019, 09:15:40 PM »
Thanks Bruce

I'll try it.
Am I wrong when I remember reading about it in the documentation - a long time ago?


Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: friendly url - how to?
« Reply #3 on: July 09, 2019, 09:47:46 PM »
probably - I don't remember documenting this, although I may have gone over it in training or a webinar or something.

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: friendly url - how to?
« Reply #4 on: July 10, 2019, 07:28:43 AM »




 



  If returnValue = 404 ! page not found, so check quicklinks file to see if there's a match
    Access:quickLinks.Open()
    Access:quickLinks.UseFile()
    Qui:Quick = sub(p_FileName,len(clip(self.site.WebFolderPath) & '\')+1,255)
    If Access:QuickLinks.Fetch(Qui:QuickKey) = 0
      Qui:full = clip(self.site.WebFolderPath) & '\' & Qui:Full
      ReturnValue = PARENT.ReadFile(Qui:Full,p_Buffer,p_FileDate,p_FileTime,p_Parse,pShared)
    end 
    Access:quickLinks.Close()
  End

I dont understandt wht is it code for... please explain, thanks
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11251
    • View Profile
Re: friendly url - how to?
« Reply #5 on: July 10, 2019, 11:33:58 PM »
It allows you to map a "friendly" URL to some "real" URL.

Cheers
Bruce