How Can I Add a Third Group to This Code?


#1

I am trying to add a third group (employer1) to the two existing ones I already have (employer, job seeker). I can’t get the top menu of my site working with the third group: either some of the headings show up twice or too few headings show up. As you can see from the code, there are two “if” statements being used. I’ve tried elseif and tons of variations but I can’t make it work. Is there another type of statement I should be using. Basically, I want the code to recognize either the employer or employer1 group (for each, the same menu headings should show up) and also recognize the headings when the user is a job seeker. Here’s the code. Any help would be greatly appreciated. I’ve been working on this for over a week and cannot resolve it.

Thanks,

Carrie

[php][[Home]]   
[[My Account]]   
{if $GLOBALS.current_user.group.id != “Employer”}
[[Find Jobs]]   
[[Post Resumes]]   
{/if}
{if $GLOBALS.current_user.group.id != “JobSeeker”}
[[Search Resumes]]   

 [[Post Jobs]]   
{/if}
[[Contact]]   
[/php]


#2

Didn’t we already cover this under Carrie2???

Without seeing a lot more of your code, the only thing I can say is that you are testing for

{if $GLOBALS.current_user.group.id != “Employer”}

This test for a condition and does something if NOT true… And, you follow it up with the same for “JobSeeker”…

I would think the logic is backwards there. Normally, you do an IF clause like this: (General terms!)
If (id=“Employer”){
Do this code for employer…
}elseif(id=“Employer1”){
Do this code for second employer…
}else(id=“JobSeeker”){
Do this code for id’s not equal to employer or employer1… (job seekers)…
}
This assumes that you have the three possible id’s and they will not change. If you add more, then, this sample code will change. Hope that helps…


#3

ErnieAlex,

You may have posted a reply to Carrie2 but it didn’t resolve my issue. The code seems backwards to me too. I will try again but if anyone else has some other ideas in terms of statements I should be using, I would appreciate it.

Thanks a lot for your help.

Carrie


#4

Well, normally you should repost or repost under another name. Mixes up us who are trying to help…

Anyway, I think your code is just the logic thing… First, the layout…

Since your code is inside a template or whatever, sometimes the code layout is a bit tricky.
I am sure it is the flow of the if-then’s! I mistyped my last post, the last (cond) is not needed.
}else(id=“JobSeeker”){ should be }else{ So, that routine handles 3 possiblities.

  1. employer 2) employer1 3) all others… So, it will not work with 4 options…

Just wanted to point that out. Good luck and let us know if you solve it…


#5

Well, that won’t work either. The way the code is written,

It says, if the user group isn’t the employer, list these things in the top menu (that way, when you visit the site and are not logged in as either an employer or a job seeker, the entire menu shows up).

Next, if you aren’t a job seeker, list these things in the top menu (that way, when you visit the site and you are not logged in as either an employer or a job seeker, the entire menu shows up)

So, when I include a third group which is exactly the same as the employer group except for the ID, the relevant top menu headers show up twice.

By writing the code any other way, messes things up because there has to be a way for the menu items to appear when not signed in as either the employer or the job seeker. Now the question becomes, how to make it work so that the second employer group works too?

Isn’t there some sort of equivalent AND statement I can use like if you aren’t either Employer or Employer1, list these things?

I have included the code for the top menu again (this is the entire code by the way).

Thanks!

Carrie
[php] [[Home]]   
[[My Account]]   
{if $GLOBALS.current_user.group.id != “Employer”}
[[Find Jobs]]   
[[Post Resumes]]   
{/if}
{if $GLOBALS.current_user.group.id != “JobSeeker”}
[[Search Resumes]]   

 [[Post Jobs]]   
{/if}
[[Contact]]   
[/php]


#6

Thank you. I now see what you are asking for.

Yes, you can combine IF’s in many ways. So, to just add another employer to an IF, you can use the OR function. So, If (employer) should be if (employer OR employer1) you would do this in this manner:

{if ($GLOBALS.current_user.group.id != “Employer”) || ($GLOBALS.current_user.group.id != “Employer1”)}

Note: On some systems, the word “or” can be used, but, the standard is the double-pipes. Also, if more than one condition is listed, normally you separate then in groups with ()'s…

Hope that helps and sorry I did not pick up on what you wanted…


#7

OK. Now we are cooking with gas! In theory this should work EXCEPT, when I’m signed in as either employer or employer1 I get all the menu headings listed (7 possible). I should only have 5 because this “if not equal to employer or employer1” statement should have eliminated 2 of the 7 possible heading choices! Any idea why this might not be working?

Thanks for hanging in here with me. I am thrilled that this might be one step away from being resolved! Yeah! Here’s the updated code with the “or” statement:

[php][[Home]]   
[[My Account]]   
{if ($GLOBALS.current_user.group.id != “Employer”) || ($GLOBALS.current_user.group.id != “Employer1”)}
[[Find Jobs]]   
[[Post Resumes]]   
{/if}
{if $GLOBALS.current_user.group.id != “JobSeeker”}
[[Search Resumes]]   

 [[Post Jobs]]   
{/if}
[[Contact]]   
[/php]


#8

Okay, since I really do not know what you want. Let’s ask some questions and then I can help you…

You have 3 areas: 1) employer 2) employer1 3) job seeker

You have these URL, so far as I see…

  1. [[Home]]
  2. [[My Account]]
  3. [[Find Jobs]]
  4. [[Post Resumes]]
  5. [[Search Resumes]]
  6. [[Post Jobs]]
  7. [[Contact]]

So, send me a list of which you want under the 3 main titles:
Employer Employer1 Job-seeker


 1              1                  1
 2              2                  2

etc… Thanks…


#9

Hi ErnieAlex!

Yeah! I figured it out! I am thrilled to have this resolved. I cannot tell you. I changed the || to && and that worked.

Thanks so much for all your help. I never would have been able to resolve this without you. I cannot thank you enough.

Carrie


#10

Great! CONGRATS! Sorry, I was so slow to “see” what you needed…

Heee, we await your next programming puzzle… LOL CYA in the bitstream…


#11

I’m not sure I really understood my problem well enough to articulate it clearly until today! Thanks again and I have no doubts I’ll be back for more advise!

Carrie