function.sessionvalue.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2015 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
12 
13 /*
14 * Smarty plugin
15 * -------------------------------------------------------------
16 * File: function.sessionvalue.php
17 * Type: function
18 * Name: sessionvalue
19 * Purpose: output a session variable value
20 * Usage: e.g. {sessionvalue name="platform"} or
21 * {sessionvalue name="platform" varname="platform"}
22 * -------------------------------------------------------------
23 */
24 function smarty_function_sessionvalue($params, \Smarty_Internal_Template $template) {
25  $session = ObjectFactory::getInstance('session');
26  $value = $session->get($params['name']);
27  if (isset($params['varname'])) {
28  $template->assign($params['varname'], $value);
29  }
30  else {
31  echo $value;
32  }
33 }
34 ?>