P
P
photosho2017-09-13 11:05:30
1C-Bitrix
photosho, 2017-09-13 11:05:30

How to add an HTML input field to the component parameters?

How can I add a field for entering HTML code with a visual editor to the list of component parameters? There is no parameter type 'HTML'.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Emelyanov, 2017-09-13
@photosho

The customer needed a component that displays a simple HTML code (markup) on the site. Why a component? Because it combines html / js / css - thus, certain "blocks" are created that the customer himself wants to add. The blocks are quite simple (stylized text and pictures), and a visual editor would be quite suitable for their implementation. Therefore, I wanted to add a field with HTML code in the component parameters and then display the value of this field in the component template.
If you have any ideas on how to implement it better, I'll be glad to hear them.
The topic is popular and there are a lot of tricks with ears.
One of the possible ear flips is as follows: make an IB, name it, for example, "Content blocks". Add 4 properties: HTML(type:string), CSS(type:string), JS(type:string), IMAGES(type:file,plural). (You can use the PREVIEW_TEXT and DETAIL_TEXT fields for some properties)
+ Make a simple component, in which in the settings you only select the IB element to display. This component outputs html, css and js properties (current css and js in their respective wrappers). If you need to insert images into this block, then you load them into the IMAGES property, and then paste the resulting path into html.
I like this solution because all content blocks are not scattered around the site, but are stored in the database. Those. for example, you can turn off some immediately in bulk if some promotion is over (no need to jump around the site). Another plus is that if you delete an IB element, then its images will be deleted along with it, thereby we pollute b_file, /upload/ and the system as a whole less. Content blocks in IB can be divided into sections, it becomes relevant when their number exceeds 100.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question