So, right now the code gives you two different layout options based on whether or not your $reviewSidebarEnabled variable is true.
- Option 1:
<div class="main-content-left">
- Option 2:
<div class="main-content full-width">
(Notice there is NOT a dash between main-content and full-width in the second option there.)
And what you WANT to do is add a third option based on whether or not a new variable called custom_field_value is set to "full" or not, right?
The original two choices would remain, but you want to add a third option that would take precedence over the other two like so:
- Option 0 (NEW):
<div class="main-content-full-width"> WITH a dash
- Option 1:
<div class="main-content-left">
- Option 2:
<div class="main-content full-width">
I don’t really understand why you’d want to allow yourself to get confused by two very similar classes: "main-content-full-width" and "main-content" with "full-wdith" might get confusing. I’d recommend changing your new custom_field_value class to something simpler, like <div class="main-content-full">.
Anyway, if you want to do that, this code should probably do the trick:
<?php if($custom_field_value === "full") { ?>
<div class="main-content-full">
<?php } else { ?>
<div class="main-content<?php if($reviewSidebarEnabled) { ?>-left<?php } else { ?> full-width<?php } ?>">
You basically wrote it out yourself already.
Thread Starter
maraki
(@neodjandre)
yes that’s what I want exactly… i just don’t know how to code it in PHP..
The code I gave you there at the end of the first comment should work:
<?php if($custom_field_value === "full") { ?>
<div class="main-content-full">
<?php } else { ?>
<div class="main-content<?php if($reviewSidebarEnabled) { ?>-left<?php } else { ?> full-width<?php } ?>">