I am referencing switch thats in the include file on an html page:
bpost.php
<?php
switch ($bpost) {
case "2":
$VAR2 = "Template 1";
$BLOG_TITLE = "Template 2;
break;
case "1":
$VAR2 = "Template";
$BLOG_TITLE = "Template ";
break;
default:
$VAR2 = "Blog";
$BLOG_TITLE = " Blog";
}
?>
in my html file i have include(“include/bloginfo.php”);
When I want to use the case variables to fill in data, I have to reference the include everytime like this.
<li>
<?php $bpost = "1"; include("include/bloginfo.php");?>
<div class="post-info">
<a href="<?php print $LINK; ?>"><?php print $BLOG_TITLE; ?></a>
<div class="post-meta">
<?php print $VAR2; ?>
</div>
</div>
</li>
<li>
<?php $bpost = "2"; include("include/bloginfo.php"); ?>
<div class="post-info">
<a href="<?php print $LINK; ?>"><?php print $BLOG_TITLE; ?></a>
<div class="post-meta">
<?php print $VAR2; ?>
</div>
</div>
</li>
Is there a better way to do this so I only include the bloginfo.php file at the begining of the page, and I can <<?php $bpost = “2”; > around the divs I would want the data to populate inside of?
Right now, I am just referencing the include around the divs I need the data to populate, which seems like I am loading the data redundantly.
Rick Uppal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.