Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
getting user name from a tpl
Annad
Hi,
Is there a way to retrieve the current user name from within a tpl file.
I believe that just like the iwpt_get_dcr_name() to get the dcr, there will be one for users.
I can't find the location for these tpl methods.
Thanks.
Anna
Find more posts tagged with
Comments
Migrateduser
I think you would check an environment variable. But if generation is running as an ExternalTask under Windows, this may just show SYSTEM. Why do you need to do this? Maybe you could (more reliably?) call iwattrib to get the last user to modify the DCR?
Annad
I need to know the user who acutally generates the final shtml page. I thought that just like a DCR is connected to the tpl when the tpl is executed, the user who exectues the tpl would also be accessible.
The reason I need this is because I am trying to creat a log file each time a tpl is excuted and the best way to name the log file (which should be a unique name) will be to name it with the name of the user.
Migrateduser
Interwoven probably does or should expose that somehow, but from what I know I think environment variable might actually work and should already be defined. I would put the logic in iwpt_compile.ipl (or wrap iwpt_compile.ipl with your own logic) instead of each TPL. And you may not want to log previews, only generates? And not log if it is SYSTEM or root or whatever other non-user users may appear.
Logging all the params passed to iwpt_compile.ipl can be really useful for debugging.
Jens
you can use formapi to get and save a user in DCR/DCT and than get this information in your PT.
but this doesn't work if the DCR isn't modified before or an other user generates the page than the one who modified the DCR.
we use this to display a "last modified by"-info on the html-page.
maybe this is an option for you.
otherwise, just an idea, you can read the teamsite-cookie, i have never done this, but i read that in devnet a few week ago.
Ciao,
Jens
herald10
You can always get the username from the cookie. Retrieve the environment variable HTTP_COOKIE, it has the info you are looking for.
Annad
Thanks for your help.
The tpl that I was talking about was a presentation template. An external task in the workflow is using this to generate the final .shtml page. When I tried the HTTP_COOKIE environment variable, it worked when I 'Regenerate Page' for the shtml page directly from TeamSite. However when the page is created by the workflow, the workflow engine does not set an HTTP_COOKIE environment variable, so the presentation template is not able to retrieve the user that way.
I also tried setting up an environment variable in the workflow template for the user, but still can't retrieve it in the tpl file.
Any ideas how I can
Migrateduser
I think the idea of setting a field with the username in FormAPI makes sense, but it will be the last user to edit the DCR, not the last user to manually generate. If you really need the user that last generated, maybe have the TPL (or iwpt_compile.ipl) set an extended attribute on the DCR (not the output file, as it may not exist during generation) with the username from the cookie or other environment variable, if it is available, then if it's not available use that attribute. You may need multiple variables on the DCR if you generate multiple output files from a DCR.
herald10
I think you can use iwpt_compile.ipl to generate the file and use iwpt_arg flag to pass the user name to the presentation template. You might want to set the EAs on the generated file from within the workflow.