1
sceilig
problem including a smarty file
  • 2006/3/19 22:18

  • sceilig

  • Just popping in

  • Posts: 53

  • Since: 2006/3/1 1


I am trying to include a different admin navigation theme file depending on the permissions of the administration group logged into the backend area. I tried doing the code with just smarty but had difficulty, so I thought I could make it happen using php. However, when I try and include a file containing smarty code, it doesnt render it correctly - the smart code in the included files gets displayed to the browser.

What am I doing wrong, and also, how could the below be performed using just smarty coding?

Quote:

<{php}>
global $xoopsUser;
if ($xoopsUser) {
$groups = $xoopsUser->getGroups();
$special_group_id = 4;
if (in_array($special_group_id,$groups)) {
include("../../themes/default/navigation/theme_adminnav_special.html");
} else {
include("../../themes/default/navigation/theme_adminnav.html");
}
}
<{/php}>


Note, I also had to use relative paths to include the theme files which doesnt seem right - smarty includes them like
<{include file="default/navigation/theme_adminnav.html"}>

2
Quest
Re: problem including a smarty file
  • 2006/3/19 22:36

  • Quest

  • Friend of XOOPS

  • Posts: 1034

  • Since: 2005/11/19


I don't know if you have to do it with the php but try this and see if it works. It looks like you are missing < > for your includes.

<{php}>
global $xoopsUser;
if ($xoopsUser) {
$groups = $xoopsUser->getGroups();
$special_group_id = 4;
if (in_array($special_group_id,$groups))
<{
include file="default/navigation/theme_adminnav_special.html"
}> else
<{
include file=""default/navigation/theme_adminnav.html"}>

}
<{/php}>

3
sceilig
Re: problem including a smarty file
  • 2006/3/20 10:43

  • sceilig

  • Just popping in

  • Posts: 53

  • Since: 2006/3/1 1


Quest,
That didnt work for me. However, I did get it to work in a sortof convoluted way, by closing the php tag before including the smarty file, and then opening the php tag again.

Quote:

<{php}>
global $xoopsUser;
if ($xoopsUser) {
$groups = $xoopsUser->getGroups();
$special_group_id = 4;
if (in_array($special_group_id,$groups)) {
<{/php}>
<{include file="default/navigation/theme_adminnav_special.html"}>
<{php}>
} else {
<{/php}>
<{include file=""default/navigation/theme_adminnav.html"}>
<{php}>
}
}
<{/php}>


Surely there is a more elegant way of doing this?

Login

Who's Online

211 user(s) are online (163 user(s) are browsing Support Forums)


Members: 0


Guests: 211


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits