Hello, I need to check which member_group a person is then display appropriate hard coded forum, link and description.
I have created my own index.php file for the discussion forum so I can have discussion forums display a description and the job posting boards to just have single line titles (because there are so many.)
On the last box of Discussion forums I want to only show the chat forum for there specific group (which I will hard code the forum title, link and description.)
{if member_group == "1"}
<a href="#">Admins chat board</a>
description
{if:else member_group == "2"}
<a href="#">Graphic Artist chat board</a>
description
{if:else member_group == "3"}
<a href="#">Programmers chat board</a>
description
{/if}
but in php
1) Why are you using a modified index.php file for the discussion forums? This sounds like something you can accomplish in your themes, as the index.php file is not one you want to modify.
2) You are correct that conditionals are not parsed in the forum themes, except for the conditionals that there are specific handlers for (like those that you see in the default themes). You have some options that don’t require a hack. One is to run the forums through the regular template engine, which will allow for conditionals you have above. Another is to enable PHP in the discussion forums, and use $SESS->userdata[‘group_id’] in PHP conditionals.
Hello Mr. Jones, Thank you for responding;
Why are you using a modified index.php file for the discussion forums? This sounds like something you can accomplish in your themes, as the index.php file is not one you want to modify.
Well, there are several reasons and I’ll attempt to explain the major ones. a) The emulation look of the “All” forum Categories and there groups looks just like that of individual Categories and there groups, so I thought I would utilize the forums landing page (index.php [“all” showing]) for more content. b) Utilization of the landing page for better SEO stepping, leading not just to categories but also other areas of the website (which I have not utilized just yet [will be building this off of what the freelancers would like on the landing.]) c) Their are (and will be more) a large number of boards for employers/sub-contractors to post gigs/projects in, so having just single line titles helps with making a little more room for future content and to save users from having to scroll way down to get to their corresponding board. d) I don’t use EXP: (template embeding) for the forums for several reasons which need not be explained here. e) Sense the next version will be 2.0 I see no reason to not hack up the 1.6+ version lol. (I’ll utilize the 2.+ version for the next ver. of fjf a few years down the line.)
You are correct that conditionals are not parsed in the forum themes, except for the conditionals that there are specific handlers for (like those that you see in the default themes). You have some options that don’t require a hack. One is to run the forums through the regular template engine, which will allow for conditionals you have above. Another is to enable PHP in the discussion forums, and use $SESS->userdata[’group_id’] in PHP conditionals.
Ahh! that may be the answer.. I did hard code a function utilizing the $SESS, and of course did not work, but from what you’ve mentioned above may work by enable php?.. is this in reference to EXP in templates? or is this as it stands alone?
Thank you in advance.
Corvaire, I still see absolutely nothing about what you are saying that would require or even make it a good idea to modify your index.php file. You should be building all of your content in your themes and/or templates.
Yes, you must enable PHP parsing for the forums in the board preferences.
<?php
global $SESS;
if ($SESS->userdata['group_id'] == 1):?>
You are a Super Admin
<?php elseif($SESS->userdata['group_id'] == 5): ?>
You are a member
<?php endif; ?>
embeding the function with in my td tags:
{include:chat_forums}
and creating a function with your suggestion:
when I saw it was wrapped with the php I realized this probably wouldn’t work because it’s with in a php tag already. I tested and of course have an error for each php wrap. Where should I go from now?
Well, that didn’t work.. How about this? adjustments I should make? Comes back no errors, but displays nothing:
//-------------------------------------
// Chat Forums
//-------------------------------------
function chat_forums()
{
global $SESS;
if ($SESS->userdata['group_id'] == 1)
{
$line = 'Group ONE';
}
elseif($SESS->userdata['group_id'] == 2)
{
$line = 'Group TWO';
}
}
/* END */
I put this in the mod.forums file and included the function in the cell I need it in.
I GOT IT WOOT!!
//-------------------------------------
// Chat Forums
//-------------------------------------
function chat_forums()
{
global $SESS;
$str = '';
if ($SESS->userdata['group_id'] == 1)
{
$str .= 'Group ONE';
}
elseif($SESS->userdata['group_id'] == 2)
{
$str .= 'Group TWO';
}
return $str;
}
/* END */
Yes, it does hold html!! Don’t forget to define the function as shown below; “into the mod file and declaring the function for the index_theme class name”
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.