I'm trying to find a way to get Div ID values from an included file's html and use them for comparison in a php if statement. I have a page called templates.php which uses a href value to grab a certain template, in this case fullwidth.php Initially, this gets the value from the URL and if it's 1 it loads the full page template, else it loads the half page template. That functionality works fine:
<!-- Get value from href -->
<?php $value = isset($_GET['value']) ? $_GET['value'] : 1;
if($value == 1){
include 'class/fullWidth.php';
}else{
include 'class/halfWidth.php';
}
?>
Once $value
dictates what template to load, I'm trying to set a value $panelType
off of the panel Div so I know which panel type to save to my database. For example, on my fullwidth.php page I have one full width panel:
<div class="col-lg-12 fullWidth" id="full">
<div class="fullContent" style="background-color: white; height: 100%;">
</div>
</div>
so back on templates.php, I would take the #full
as the div ID and use this to set my variable $panelType
.
Which is where I add this and try:
<?php $value = isset($_GET['value']) ? $_GET['value'] : 1;
$panel = $html->find('div[id]'); //including this to pull in DIV IDs
if($value == 1){
include 'class/fullWidth.php';
if($panel == 'full'){
$panelType = 1;
}// including this block to say if the Div ID is 'full', set $panelType = 1
}else{
include 'class/halfWidth.php';
}
?>
But this breaks the pages and it looks like a general php or formatting error. I'm not sure what exactly I'm doing wrong here, maybe there's a better way to use the div ID I want for the php variable. Eventually I will expand this so I just want to know how I can modify this to just say "If the Div ID is this, set the $panelType to this, etc."
you can just set the $panel inside your fullwidth template like:
$panel = "full";
<div class="col-lg-12 fullWidth" id="full">
<div class="fullContent" style="background-color: white; height: 100%;">
</div>
</div>
and then when you load it, the second code you wrote will work ;)
but that only works, if you can set the panel manually? if there can also be other "panel id's" then this will not work and I think you have more then one id's?
if the id will always be full, i dont see why you need to check that?