Joe Weinpert
asked on
Appending user name to menu external URL link. Joomla! 3.4.3
We added a menu item to our new Joomla intranet page. it is simply an application's url link set in the Menu Manager: Edit Menu Item page like this:
Menu Item Type = External URL
Link = http: //server/pio/pio.html
Target Window = New Without Navigation
It works fine. The application fires as it is supposed to. What we would like to do at this point is append the Joomla user's login name to the link so that it automatically logs them in to the app instead of prompting for a user ID again. This is what the URL link would need to look like if I were to click on the menu item to run the external app without being prompted for a user ID:
http: //server/pio/pio.html]?userID=jweinpert
So how can we append the Joomla's user login ID to the Menu Type Item External Link whenever a user clicks on it?
Menu Item Type = External URL
Link = http: //server/pio/pio.html
Target Window = New Without Navigation
It works fine. The application fires as it is supposed to. What we would like to do at this point is append the Joomla user's login name to the link so that it automatically logs them in to the app instead of prompting for a user ID again. This is what the URL link would need to look like if I were to click on the menu item to run the external app without being prompted for a user ID:
http: //server/pio/pio.html]?userID=jweinpert
So how can we append the Joomla's user login ID to the Menu Type Item External Link whenever a user clicks on it?
Menu items are printed through mod_menu, with the view being selected according to the type of menu item. The default view, which is applied to external URLs, is found in /modules/mod_menu/tmpl/def ault_url.p hp. If you create an override for this file, you can check for a logged in user and append the username as the item is being printed.
Instead of a template override, you may want to consider a chrome style, or an alternate view. These will let you target the menu item individually instead of having all your menu items go through the new view.
Instead of a template override, you may want to consider a chrome style, or an alternate view. These will let you target the menu item individually instead of having all your menu items go through the new view.
ASKER
panagiotiss -
I am assuming that your solution would be to create a custom module through the module manger for this?
I am assuming that your solution would be to create a custom module through the module manger for this?
ASKER
Steve Bink -
I will dig deeper into your solution.
I will dig deeper into your solution.
>>> create a custom module through the module manger for this
While a custom module work also work, I think it is a bit of overkill for this problem. All you need is a small adjustment to how an item is rendered. That item already exists in Joomla, and Joomla provides overrides as a method of accomplishing this very task.
While a custom module work also work, I think it is a bit of overkill for this problem. All you need is a small adjustment to how an item is rendered. That item already exists in Joomla, and Joomla provides overrides as a method of accomplishing this very task.
yes you can put the link into a module
ASKER
Steve Bink
I am using Joomla! 3.4.3. The link you posted that am looking at is for Joomla! 2.5
so ...
I made a backup copy of the original /modules/mod_menu/tmpl/def ault_url.p hp and inserted two lines into the original:
This works fine.
Thank you for pointing where to go!
I am using Joomla! 3.4.3. The link you posted that am looking at is for Joomla! 2.5
so ...
I made a backup copy of the original /modules/mod_menu/tmpl/def
$flink = $item->flink;
// Added user to menu link ------------
$user = JFactory::getUser();
$flink .= "?userID=" . $user->username;
// ------------------------------------
$flink = JFilterOutput::ampReplace(htmlspecialchars($flink));
This works fine.
Thank you for pointing where to go!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if a user is logged in you can easily can get his credentials so the link will be something
http: //server/pio/pio.html]?use