rejetto forum

Disable diff template inheritance

0 Members and 1 Guest are viewing this topic.

Offline omnsicient

  • Occasional poster
  • *
    • Posts: 2
    • View Profile
Can someone please tell me if it's possible to disable diff template inheritance.

Reason being:

On my root folder / - I have a diff template of "{.redirect|/~login.}" which means that the moment a user browses to the root it asks them to login - once they've logged in the user redirection takes over and redirects them to their user folder, but because /redirect/~login is inherited a loop is created...

e.g. John browses to "http://www.myhfs.com/"
because he's gone to the root folder it automatically redirects him to the login page, he enters his username & password, HFS sees that John's account is supposed to be redirect to "http://www.myhfs.com/john" after logging in.

The problem:
.redirect|/~login is inherited by all child folders - meaning an endless loop is created when HFS tries to redirect John to /John - because the diff template is inherited HFS immediately redirects John back to /~login - which of course redirects him back to /John and so on.

I don't want to restrict access to the root folder to force immediate login - because then the account redirection doesn't work.

Thanks for any help


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
welcome!
try this instead

{.if|{.length|%user%.}
|{:{.section||back=1.}:}
|{:{.redirect|/~login.}:}
/if.}
« Last Edit: August 17, 2012, 12:01:38 AM by rejetto »


Offline raybob

  • Tireless poster
  • ****
    • Posts: 454
    • View Profile
    • FileSplat.com
I think you could just put the path to the master template in the diff template section where you don't want the one above it to apply.

Like if you have /folder/ with a diff template you don't want to apply to subfolders, make the diff template of the subfolders just hfs.tpl.

I haven't tested that but it should work.


Offline omnsicient

  • Occasional poster
  • *
    • Posts: 2
    • View Profile
{.if|{.length|%user%.}
|{:{.section||back=1.}:}
|{:{.redirect|/~login.}:}
/if.}

That's worked briliantly - I spent an hour and a half yesterday trying to mess around with some if statements but didn't get anywhere.

My understanding is that if the user variable is populated, i.e. logged in, then we go back to the original template section and ignore the rest of the diff template, otherwise redirect to the ~login page. I must admit it's taking me a little bit of time to grasp the syntax for HFS scripting - I've only ever worked with VB.

I discovered HFS yesterday and spent almost 8 straight hours playing with it to learn what I can do with it - it does exactly what I want in both simplicity and customization.

Thank you!


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
yes, syntax is terrible. It wasn't designed to be a programming language.


Offline h13.Bishop

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
Though there is no option to turn off directory options inheritance?

If I change root folder properties then all folders automatically inherit changes.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile