Answer the question
In order to leave comments, you need to log in
How to make several page layout options depending on the value of a variable?
Good afternoon!
There is a task to make several options for page layout, depending on the value of the variable.
Let's say there is a row (.row) that has three blocks (width=33%) and each has an image. It is necessary that the number of blocks in a line can be changed by simply replacing the value of a variable. Below I will describe the logic:
Variable other_photo = 3
If other_photo = 4, then display 4 blocks in the line (width=25%)
otherwise, if other_photo = 3, then display three blocks (width=33%), and do not show the fourth block
otherwise, if other_photo = 2, then display two blocks (width=50%) - hide the rest
otherwise, if other_photo = 1, then display one block (width=100%) - hide the rest
This should be written in PHP. I understand the logic, but I don't know the syntax. Please help!
Thank you!
Answer the question
In order to leave comments, you need to log in
There is already an entry with that id.
You need not insert but update.
you yourself wrote everything.
We get the value of the variable, as I understand it from the theme settings.
and in the markup we check its value and display the markup that we need
<?php if($other_photo == 4) : ?>
разметка
<?php elseif($other_photo == 3) : ?>
другая разметка
<?php elseif($other_photo == 2) : ?>
третья разметка
<?php else : ?>
минимальная разметка
<?php endif; ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question