Custom code. Processing "arbitrary code"

Processing "Custom code" is intended for compiling and executing custom 1C:Enterprise 8 code in user mode. This processing is intended primarily for implementation specialists and experienced users. Developed based on Query Console processing.

Processing provides functions:

  • execution of arbitrary code (entirely or selected text),
  • designing queries (with re-opening for editing) with automatic or manual filling of parameters,
  • setting the values ​​of variables found in the code text (via context menu or drag-and-drop),
  • inserting the described variables (parameters) into the code text,
  • error analysis during code execution,
  • saving code fragments and parameter values ​​to a file for storage between work sessions.

Thus, processing can be used as a repository of universal mechanisms that can be executed within a single procedure.

Description of the dialogue

The processing dialog is divided into three main blocks.

Tree of code snippets

In the upper left part of the processing there is a tree of code fragments compiled by the user. It is possible to add, delete, or move elements of this list. By double-clicking on a line in the tree, the selected code fragment is executed. The tree is controlled using a block of buttons on the processing command panel.

The processing provides a mode for automatically saving code fragments. To do this, you need to use the command panel button to call up the autosave settings dialog, enable autosave mode and set the desired interval for automatically saving queries to a file.

Code snippet options

The "Parameters" button opens a panel in which you can specify a list of query parameters and variables used in the code.

The first column indicates the name of the parameter.

The second column indicates the actual code parameter, which can be specified directly by the value.

The parameters are filled in automatically when the request is developed by the designer. In addition, parameters can be added manually by adding rows to the table or from the context menu of the code text field, or by dragging a variable into the parameters table.

Code text

At the bottom of the processing is the actual code text. The snippet that is displayed depends on the current line of the code snippet tree.

Hi all! I have a short instruction planned for today - just like on the blog for users coming from search, display a custom code anywhere in the template.

I found a practical application for this method a couple of months ago. At that time, for visitors from search engines An invitation to subscribe to the newsletter was displayed under the header.

As you understand, the line was displayed only once - during the first transition from the search engine, then when surfing through the pages it disappeared and did not appear again. Of course, if the same user does not return to the blog again.

I used a subscription as an example, but you can also organize the display of advertising lines, any advertisements, and so on. And naturally, the location is not limited to the header; this code can be displayed anywhere in the template. Let's proceed to the practical part of the script implementation.

Function that determines the source of the request (HTTP referer)

First of all, let's create new feature fromsearch (conventional translation - “from search”), the name of the function can be anything, the main thing is to keep in mind and use the accepted name in the future. This feature is for determining the transition source- be it PS, another site, etc. We are interested in PS. So, on WordPress we insert the code into the functions.php template file:

function fromsearch()( $ref = $_SERVER["HTTP_REFERER" ]; $SE = array ("/search?" , "images.google." , "search." , "yandsearch" , "/search/" , ".yahoo." ); foreach ($SE as $source) ( if (strpos($ref,$source)!==false ) return true ;) return false ;)

Please note that the third line indicates the agents for which the rule will be executed and arbitrary code will be shown in the future. This completes the main part, all that remains is to display the function in any convenient place.

Output of arbitrary code when transitioning from search engines

The next step is to display the predefined function on the page. To do this, we use the following lines, which we insert into the template file; for example, I use index.php:

class="showfromsearch" > CUSTOM CODE div >

For example, my complete code with subscription looked like this:

class="showfromsearch" > <div class ="warning" > New to the blog? Subscribe to our newsletter!div > div >

That's it, the output of the function is complete, let's move on to the next step.

Design styles for the block that displays the code for visitors from the PS

All that remains is to assign to the class showfromsearch design styles, adjust to fit, adjust position relative to other blocks. If everything above can be used immediately, without making changes, then there are no specific solutions for custom design.

It all depends on the layout and the place where it is displayed this function. Externally, my line, which I give in the example, looked like this:

The block marked with a red arrow is shown only to users who came from search engines; for all other transitions it is not visible. I’ll give my example, for which I set the design style in the style.css file:

.showfromsearch ( width :900px ; border :0 ; text-align :left; margin :auto; padding :0 ; )

And again I draw your attention: this style is assigned to a block with a function, i.e. we configure exactly the appearance and location of the block itself, and not what is in it. The internal content uses its own styles. If you look at the screenshot above where I displayed the subscription, then the frame around the line, background and image are assigned to a different class ( warning), which contains the text.

This way any code for transitions from search is displayed, I’ll probably repeat - using this method you can show others, while regular readers coming from bookmarks, direct visits or links on other sites will not see this content.

Today I would like to tell you how, using WordPress as an example, to add arbitrary HTML code in the right place. Be it a counter code or a subscription code to your channel, advertising, and so on. We will insert the code through the standard WordPress widget.

WordPress – add custom HTML code.

There is always a need to insert arbitrary HTML code, make a beautiful subscription to your channel in the sidebar, or simply place text on home page, there are a lot of options, it all depends on your needs.

IN latest versions WordPress already has a built-in widget for adding custom HTML code, so there is no need to install separate plugins.

And so, in order to add our code, we need to go to the “tab” in the admin panel Appearance” -> “Settings”. It is also possible through widgets, but then we will not see the result immediately. I prefer a visual editor.

We select the place where we want to add our code. I want to add a counter to the sidebar. Select “Sidebar”, your name may differ, it all depends on the template.

A new widget will appear, open it and enter our code into the content, do not forget to save.

As a result, we get the following result.

This way you can add HTML code anywhere you want to use widgets.

That's all, I hope this article was useful.

  • " onclick="window.open(this.href,"win2","status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories =no,location=no"); return false;" > Print
  • Email

In this tutorial, we'll look at how to display additional content on your site using the Custom HTML module. It will also show how to translate the contents of this module into another language using the component Joom!Fish.

Introduction

Module " Custom HTML code"is a standard module CMS Joomla, with which we can add HTML code to any place on the site page that is allowed by the site template. Using this module, it is convenient to add not only text with graphics, but also various scripts and informers.
In this tutorial we will show you how to use the "Custom HTML Code" module, as well as how to use this module in a component to create translations into other languages ​​- Joom!Fish.

First, we will create a “Custom HTML Code” and add this module to the main page of the “We Ride Ourselves” website. Then we will show how to make changes in this module for the Russian and Ukrainian languages ​​of the site. More precisely, we will change the heading “New Year in the Carpathians...” to “In the Carpathians...”, and then replace the object “Chervona Ruta” with “Polyana Kvasova”.

Creating a module based on "Custom HTML code"

To create a module "Custom HTML code" you need to go to the "Modules Manager" (in the "Extensions" menu). Then you need to click the “Create” button and select the “Custom HTML code” module from the list. A module window will open, where you need to enter a title, enable it, and also enter the desired (your) HTML code in the “Custom text” form. We entered “Hot Deals” as the title and set the position at the bottom of the site by selecting “footer” from the list for the “Position:” item. Since we want our content to be displayed only on the main page, we need to check “Select from list” in the “Menu Purpose” column opposite “Menu:” and select only “Home” in the list (Fig. 1). and click the “Save” button. Working with the “Custom HTML code” module is described in more detail in the lesson “Adding custom HTML in the joomla module using the example of a weather forecast informer”.

Working with module translation using the Joom!Fish component

After creation, our module will appear on the main page.
To change anything in a module, you just need to go to the “Modules Manager” in the admin panel and then go to our module, where we visually make our changes.

In some cases, it is convenient to make a translation in another way - through the control panel of the Joom!Fish component.
To translate the module in the second way, you need to go to the “Components” menu and select “Joom!Fish” - “Translation Management”. Next, click the “Copy of the original as a translation” button, select the “Modules” item from the list and select the desired language from the “Languages” drop-down menu (located on the right). We have two languages ​​on our website: Russian (by default) and Ukrainian (Fig. 2). In our case, we choose the Ukrainian language.


After selecting the language, a list of modules will appear in which we must find our module and go into it. A window called “Translation” will appear, in which we can translate our module into another language. In our case, we replace the object “Chervona Ruta” with “Polyana Kvasova” (Fig. 3). After clicking the “Save” button, our translation of the module will appear on the main page of the site (Fig. 4).




If you want to look video lesson with detailed all the steps, you can download the archive with the video lesson from the link.

If you need to insert arbitrary code into posts and pages of a WordPress site, you can use the Global Content Blocks plugin. The plugin is not heavy, allows you to quickly and conveniently insert it into an article or page HTML codes, PHP, custom codes, subscription forms, AdSense advertising, text blocks. You can use it to insert php code into the website template and place blocks in two or three columns. The plugin is constantly updated and can be considered one of the best WordPress plugins.

Download and install

We go through the standard steps. If you install plugins at , I’ll give you the address official page plugin: https://ru.wordpress.org/plugins/global-content-blocks/

Setting up the Global Content Blocks plugin

There are no plugin settings as such. After activating the plugin, a menu appears in the console: Global Content Blocks. On the plugin page we see control tabs:

  • Manage Blocks (1) - manage plugin blocks;
  • Add a Content Blocks (2) - adding blocks;
  • Setting (3) - import blocks from another site.

Also, a button for adding plugin blocks appears in the site editor.


button to add Global Content Blocks in the editor

Insert custom code into WordPress posts and pages using the Global Content Blocks plugin

Working with the plugin is easy:

  • Go to the block adding page;
  • Give the new block a name (1),
  • We give it a Latin name for the shortcode (2);
  • Select the content type (3);
  • You can select a picture (5) to be placed in the block;
  • Insert the contents of the block (4).

Create a new Global Content Blocs

Publications on the topic