Problem when using Dataface_Application_Menu.html
Archived from the Xataface Users forum.
geller — Wed Nov 22, 2006 4:49 pm
I am wanting to use a unique ‘Dataface_Application_Menu.html’ file for each user. The problem is that it appears that this file persists in the template_c/default directory. I belive that it is a compile issue within the ‘smarty templates’.
Is there a way to force this file to be re-compiled for each user or deleted or some other solution?
Any help appreciated
Graham
shannah — Wed Nov 22, 2006 5:33 pm
Hi Graham,
This file is a Smarty template, meaning that it can do dynamic things. If you want something different to be displayed for different users, perhaps adding some if/else clauses to decide what to display inside the Dataface_Application_Menu.html file. E.g.:
- Code: Select all
- `{if $ENV.username==’John’}
lt;ligt;Item lt;/ligt;-
Item 2
-
… etc …
{elseif $ENV==’Sue’}
-
Sue’s Item 1
-
Item 2
{/if}
- Common item`
-
Or if you want to keep john and susan’s menu in separate files you could do:
- Code: Select all
{if $ENV.username == 'John'} {include file="John-menu.html"} {elseif $ENV.username == 'Sue'} {include file="Sue-menu.html"} {/if}
Then you would add templates named “John-menu.html” and “Sue-menu.html” to your templates directory.
Or, perhaps you want to make something a little more extensible, and have files included with the naming convention “%username%_menu.html” so that John’s menu would be stored in a template named “john_menu.html” and Sue’s menu would be stored in a template named “sue_menu.html”, etc… You could do something like:
- Code: Select all
{include file="`$ENV.username`_menu.html"}
Hope this helps a little.
-Steve
geller — Thu Nov 23, 2006 4:21 pm
Hi Steve
As usual you are ‘on the ball’ I have tried the 3rd option and that will work fine but for one issue. When accessing the login page, before logging in, there is a smarty error ( because there is no username yet! I presume)
{include file=”$ENV.username.inc”}
Smarty error: unable to read resource: “.inc” in /httpdocs/dataface-build/lib/Smarty/Smarty.class.php on line 1088.
Can this error message be supressed or could an alternative login page be used and then load the application_dataface_menu.html after login?
Cheers
Graham
shannah — Fri Nov 24, 2006 2:58 pm
Hi Graham,
Wrap your menu in an If statement to avoid this:
- Code: Select all
{if $ENV.username} {include file="`$ENV.username`.inc"} {/if}
-Steve
geller — Sun Nov 26, 2006 3:57 pm
Cheers Steve thats done it.