Loading...
 
Skip to main content

Development


include_php in smarty template

hello there

a long time ago i hacked some tikiwiki files to fit my needs.
everything went fine, and anybody was happy.
but now i realised that i cant update tiki, because all my 'extensions' would be gone...

well, so i am trying to get rid off my hacks and put them where they belong... the templates.
and here comes the question...

in tiki-list_blogs.tpl i have to change all usernames to nicknames.
the usernames stored in the db are some stupid ldapnames, so every user has a nickname stored in tiki_user_preferences.

my first guess was to include a php file in my tpl, which is loading all nicknames, and then puting the nicks in the right place. but this seems not to be that easy...

can anybody tell me how to make a sql query in this include file ?
maybe there is some tiki function like get_all_user_preferences_called_nickname_from_all_user or something like that ?


thank you,
bacca

hi everybody

this is what i did so far...

first i used the smarty include_php command.

Copy to clipboard
smarty: {include_php file='path/to/load_nicks.php'}



and my php file looks like that.

Copy to clipboard
php: //this script may only be included - so its better to die if called directly. if (strpos($_SERVER["SCRIPT_NAME"],basename(__FILE__)) !== false) { header("location: http://www.daveundyona.de"); exit; } global $tikilib, $smarty, $listpages; for ($i=0; $iget_user_preference($login, 'nickName', ''); if (!$nick){ $nick = $login; } $listpages[data][$i][nick] = $nick; } $smarty->clear_assign('listpages'); $smarty->assign('listpages', $listpages[data]);


ok, i know, not that sexy but it works 😊


bacca