V
V
Vladimir Kai2016-09-09 10:03:42
HTML
Vladimir Kai, 2016-09-09 10:03:42

How to pass Bitrix catalog partition ID to javascript?

Good afternoon, dear Bitrix and PHP experts.
There was a problem:
It is required in the directory partition template to determine the value of the ID of the current directory partition.
After passing this value to javascript.
Script text:

<script type="text/javascript">
    window.ad_category = "";   <<--- Передать необходимо в эту переменную

Answer the question

In order to leave comments, you need to log in

7 answer(s)
A
Alexey Yarkov, 2016-07-26
@grishaaa

p cannot be a child of an element a

K
Kirill Kublyakov, 2016-07-26
@Kublyakov

In general, in the screenshot, the validator swears specifically at the P tag, which would be true in html4, but in html5 (and this doctype is set on your site), you can nest block elements in A tags:
https://www.w3.org/TR /html-markup/a.html#a-changes
Perhaps you need to manually select the desired doctype in the validator (select html5) and the error should disappear.

H
HamSter, 2016-07-26
@HamSter007

tag p(block element) inside а
change pto span(inline)

I
IceJOKER, 2016-07-26
@IceJOKER

It says what it means - https://translate.google.com/
The p element cannot be placed inside the a element , block elements cannot be placed inside inline elements, just the opposite (inline elements can be placed inside block elements)

M
Milok Murlyka, 2016-07-26
@milokmurlika

pcannot be placed in h1
Error can be fixed by changing pto spanor
You have an HTML5 doctype, you can wrap blocks with a link, but you can’t in this context , , if you remove a, the error will be like this:

Element p not allowed as child of element h1 in this context. (Suppressing further errors from this subtree.)

O
Oleg Maksimenko, 2016-09-09
@gold_dezmor

window.ad_category = '<?php echo $arResult['ID'] ?>';

A
Alexander Shpelev, 2016-09-09
@ibirist

If I understand the question correctly, then the category ID should already be formed in the arResult array, print it and find the correct key, and you can pass the key value through the json_encode () function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question