%META:TOPICINFO{author="TorbenGB" date="1060743593" format="1.0" version="1.5"}%
%META:TOPICPARENT{name="Main.WebHome"}%
It is possible to dynamically include a certain page, based on which user is currently logged in.

%TOC%

---+ Not logged in?

| *Do you already have a username here on %WIKITOOLNAME%?* ||
| Yes | Once you edit any page, you will be recognized from then on. |
| No  | You need to [[TWiki.TWikiRegistration][register as a user]]. |

Please note that some things might prevent you from being recognized - in these cases, just log in again: 

	* You're using a different pc than the one where you logged in. 
	* You're using a different browser software than the one where you logged in. 
	* The cookie that allows you to be recognized was deleted from your pc. 
	* The webserver is not able to recognize you for some other reason. 

---+ Create your own Personalized Menu!

<form name="new" action="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%WEB%/">
	1 You are currently logged in as %WIKIUSERNAME%, so you can create the page %WIKIUSERNAME%PersonalizedMenu by clicking this <input type="submit" value="Create my Personalized Menu!" /> button. If the page already exists, you will simply see the existing one.
	1 You'll then see your own Personalized Menu that you can add links to.
	1 Click the ==Save== button. Your new Personalized Menu automagically appears in the top left of every page when you're logged in.
<input type="hidden" x-type="text" name="topic" value="%WIKIUSERNAME%PersonalizedMenu" x-size="30" x-onFocus="javascript:this.value='PersonalizedMenu';"><input type="hidden" name="templatetopic" value="PersonalizedMenuTemplate" /><input type="hidden" name="topicparent" value="%WEB%.%TOPIC%" /><input type="hidden" name="onlywikiname" value="on" /></form>

This will create a new Personalized Menu based on the PersonalizedMenuTemplate.

---++ What is a Personalized Menu?

_Note: If you're logged in, then the table shows your own username in the examples:_

| *logged in* | *prerequisite* | *result* |
|%WIKIUSERNAME%| =%WIKIUSERNAME%PersonalizedMenu= exists | =%WIKIUSERNAME%PersonalizedMenu= is displayed |
|%WIKIUSERNAME%| =%WIKIUSERNAME%PersonalizedMenu= does not exist | nothing is displayed |
|nobody*| =TWikiGuestPersonalizedMenu= exists | =TWikiGuestPersonalizedMenu= is displayed |
|nobody*| =TWikiGuestPersonalizedMenu= does not exist | nothing is displayed |

* = When nobody is logged in, TWiki defaults the =%<nop>WIKIUSERNAME%= to =Main.TWikiGuest=. <!--View without login was tested on [[http://twiki.org/cgi-bin/view/Sandbox/TestTGB][twiki.org]] because the %WIKITOOLNAME% currently does not allow this.-->

---
---
---

---+ Technical description

---++ User Requirements

	* We want to have a personalized list of shortcuts to be diplayed between the search box and the TWiki.WebMenu.
	* Depending on what user is logged in, a personalized list of links should be displayed.
	* Each user should be able to easily define his or her own shortcuts that are displayed in the personalized menu.
	* ... other requirements?

---++ System Requirements

	* User must be logged in.
		* If we are planning to remove the required login to view TWiki, then a personalized menu will not work because it requires the current username to be defined (by being logged in).
		* This can be solved by implementing an _automated login_ based on intranet authentication, but the feasibility of that has not yet been investigated. The methods of doing this are documented in the TWiki.TWikiDocumentation.
	* The page to be dynamically included for the current user must exist. If it does not exist, and unknown state results (including a page that does not exist). Probably the result will be that nothing is included and the original page is just displayed without any included page and without any errors.
	* Each link in the users' personalized menus must be in the form of =<b>Web.</b>PageName= because if =Web.= is not specified, then the links will be broken when viewing other webs.
		* If all webs are merged into just one, then this issue will be reduced to a minor problem (it would then only affect links to other webs than the merged web).
	* In order to add new links to the personalized menu, users must edit their list manually. There is no simple way to provide a quicker/easier/userfriendlier solution without the need for programming.

---++ Implementation

In TWiki, it is possible to include a page in another page using the syntax:

=%INCLUDE{Web.PageName}%=

This can also be done in the template rather than in a page. That way, the =INCLUDE= will take effect on every page rather than on just a single page.

The syntax:

=%INCLUDE{%MAINWEB%.%USERNAME%PersonalizedMenu}%= 

will dynamically include the page =Main.%USERNAME%PersonalizedMenu= when =%USERNAME%= is logged in. Furthermore, this syntax will display the page =[[Main.TWikiGuestPersonalizedMenu]]= if nobody is logged in (becase TWiki then defaults the =%<nop>USERNAME%= to =Main.TWikiGuest= ), but this has not been verified. _If_ that works, then this page could have something like the following introduction to be displayed when being included from the template:

<blockquote>
_You're not logged in, so no PersonalizedMenu is available. [[PersonalizedMenu][Read more]]_
</blockquote>


---++ Usage

For each user, personalized menus should then be created. These should be named following the syntax given above, i.e. =initials + PersonalizedMenu=, like =Sandbox.TGBPersonalizedMenu=. If a personalized menu page does not exist for a certain user, then this user will simply not see any personalized menu. The user will not see an error message.

Each personalized menu page should look similar to this:

<pre>
	* MyFirstLink
	* MySecondLink
		* AnotherLink

%INCLUDE{Main.EditThisList}%
</pre>

to create a result similar to this:

%STARTINCLUDE%
	* MyFirstLink
	* MySecondLink
		* AnotherLink
%INCLUDE{Main.EditThisList}%
%STOPINCLUDE%


The bullet list can be updated by the user to include anything he or she wants. The user can even remove the bullet list and use any other format, though a bullet list is recommended because the list will be displayed in such a narrow area (the left-menu area).

The =%INCLUDE%= statement adds a hyperlink to the end of the list, in order to make it easy for the user to change his or her settings.

%META:TOPICMOVED{by="TWikiGuest" date="1053316503" from="Main.PersonalizedMenu" to="TWiki.PersonalizedMenu"}%
