Jump to content

If/Else Statements


DavvaM

Recommended Posts

I am trying to show a header image on my home page.

In the backend it is possible to select a checkbox for each news post and event post that will show a header image on the home page.

At the moment if I select to show an event post image it still leaves the div space above for the news post image, so we need to hide his if an event image is selected and vice versa.

Would this be possible with if/else statements?

Below are the PHP functions

<div class="col- big-news-here">
<?= $news2[0] ?>
<?= $eventsHome[0] ?>
</div>

So basically,

If news image is selected show the news div and banner

If the events banner is selected show the events div and banner and hide news div.

Many thanks

Link to comment
Share on other sites

Probably?

Consider that we have absolutely no idea who you are, what you're working with, or what kind of problem you're facing - except for what you tell us. Things like "news posts" and "header images" and "events banners" mean nothing to us unless you can describe what they are.

Link to comment
Share on other sites

Actually - Below are NOT php functions.  It is simply some sloppy php code.

<div class="col- big-news-here">
<?= $news2[0] ?>
<?= $eventsHome[0] ?>
</div>

Here is some better code:

echo "
	<div class='col- big-news-here'>
	$news2[0]
	$eventsHome[0]
	</div>
	";

Of course if you want to format it a bit you can add some more html.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.