I am trying to run specific php code depending upon what site is the URL.
the issue is that our dev team does not want to create another page, but there are 2 pages which use the same file ( the one i pasted below ). I need one page to use the data returned when the if statement is false, and if its true it doesnt need any other data to run...
I am trying to explain this the best i can, please forgive me if its confusing.
My code below works as in it says true or false. I need to run the below if its false and nothing if its true.
use this if false :
$primaryCta = [
'text' => $data['spclprictatxt'],
'href' => $data['spclprictalnk'],
];"
use nothing if true
<?php
use Febe\Helper\BeautifyText;
$image = $data['image'][0] ?? null;
$link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://" .
$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$pageCk = $link;
$primaryCta = "false";
$primaryCta1 = "true";
if ($link === 'http://heiferdev.local/account/login.html') {
echo $primaryCta1;
echo $link;
} else {
echo $primaryCta;
echo $link;
}
?>
<div class="headerSimple"
<?= !empty($data['background_color']) ? 'data-background-color="' . $data['background_color'] . '"' : ''; ?>
>
<div class="wrappers__wrapper-max">
<div class="headerSimple__header">
<?php if(!empty($image)): ?>
<figure class="headerSimple__figure">
<?= $this->returnView(
'shared/dynamicImage/dynamicImage',
[
"source" => IMGIX_URL . $image['url'],
"alt" => $image['alt-text'],
"focalPoint" => $image['focal-point'],
"focalPointZoom" => $image['focal-point-zoom'],
"parameters" => $image['parameters'],
"imgClass" => "headerSimple__figure-img"
]
);?>
</figure>
<?php endif; ?>
<div class="wrappers__wrapper">
<div class="headerSimple__headings">
<?php if(!empty($data['title'])) : ?>
<h1 class="headerSimple__title">
<?= BeautifyText::beautifyTitle($data['title']); ?>
</h1>
<?php endif; ?>
</div>
</div>
</div>
<?php if(!empty($data['lead_in_text']) || !empty($data['subhead'])) : ?>
<div class="wrappers__wrapper">
<?php if(!empty($data['subhead'])) : ?>
<h2 class="headerSimple__subhead">
<?= BeautifyText::beautifyText($data['subhead']); ?>
</h2>
<?php endif; ?>
<?php if(!empty($data['lead_in_text'])) : ?>
<div class="headerSimple__body">
<?= BeautifyText::beautifyText($data['lead_in_text'], false); ?>
<div class="homeHeader__cta-block">
<?php if (!empty($primaryCta['href']) && !empty($primaryCta['text'])) : ?>
<div class="homeHeader__cta-block">
<a class="button__secondary button__medium js-product-add-to-basket" href="<?= $primaryCta['href']; ?>">
<?= $primaryCta['text']; ?>
<img style="margin-bottom: -8px;"
src="https://toppng.com/uploads/preview/white-dollar-sign-11549435997nrl2vmgejx.png"
alt="Money Icon"
width="30px"
height="38px" >
</a>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
Aucun commentaire:
Enregistrer un commentaire