S
S
Stanislav2022-01-07 17:16:06
MODX
Stanislav, 2022-01-07 17:16:06

How to display TV - checkbox only for the current page?

Please help to solve the problem:
On some pages I plan to display a warning window through the checkbox. If a warning is needed on the page (current resource) - a tick is placed in the tv-field of the current resource.

I did the following:
1. I created a chunk that will contain this warning window.
This chunk comes by default with a value of "display: none".

<div class="none ">
    <div>предупреждающее окно</div>
</div>


2. Styles

.active{
    display: block !important;
}
.none{
    display: none;
}


3. In the page template I call this chunk like this:



4. As a result, when I check the box on the current resource, a warning window appears on all pages of the template.
Those. the "active" class is assigned to a chunk on all template pages.
How can I make the checkbox apply only to the current resource?

Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Tarasov, 2022-01-07
@zalman2

It was difficult to implement, why not like this, for example:

<div class="none ">
    <div>предупреждающее окно</div>
</div>

You call this in the template, for the page where TV is specified (in the field settings you need to specify that when it is selected, it gets the value "active"), this block will receive the desired class.
And of course, the page has a template for which this TV is attached (otherwise, you can’t specify it in the backend).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question