You're along the right lines.
Let's break down your code section-by-section
{categories}
{/categories}
This will work just fine.
{if category id == "38"}
The correct variable name here is {category_id}
(note the underscore). Getting the variable names correct is imperative when using conditionals - because else you're checking against the wrong thing.
<h4><a href="{url_title_path='product-support/service-centers'}">{facility_title}</a></h4>
No problems here
{if:else category_id == "32|30|33|31" && category_id != "38"}
This is where it starts to break down. What you have effectively written is "if it's anything but 38 do this instead". But you've hard-coded that. What if category 34 appears tomorrow? You'd be better off going for a simple {if:else}
line. That does the same thing short-hand.
The second issue is that you use {if:else}
here, but you wrote it as a {if:elseif}
statement. Notice the second if there. That allows you to basically say "If the above conditional isn't true, try this new conditional instead".
Additionally you're using piped values (|
) to check the category_id
variable. This is the syntax for selecting multiple entries but it wouldn't be outputted like that. Unfortunately in conditionals you'd have to go long hand with {if:elseif category_id=="32" || category_id=="30" || [etc]
} - that's no fun. For your reference though, doing a double-pipe (||
) in conditionals is to OR
what &&
is to AND
.
And so if we put it all back together, this code will do the job.
{categories}
{if category_id == "38"}
<h4><a href="{url_title_path='product-support/service-centers'}">{facility_title}</a></h4>
{if:else}
<h4>{facility_title}</h4>
{/if}
{/categories}