Gallery3xEmbeds

Gallery3x3 min readPage 9 of 22
On this page 4

Starting with version 3.2.1, Gallery3x ships the [[!Gallery3xEmbeds]] snippet, which outputs embedded objects (embeds) on site pages — maps, widgets, players and any iframe content added in the resource's “Embed G3x” tab.

The “Embed G3x” tab is enabled by the gallery3x.embed_enable setting.

Key feature

Each embed is added in the manager in one of two modes:

  • Link — you paste a link (for example to Yandex Maps or Google Maps), the component recognises it and builds a safe <iframe> itself.

  • Embed code — you paste ready-made embed HTML (the “Share → Embed” button on the source site); it is output as is.

The snippet passes ready HTML of the embed to the chunk in the [[+embed_html]] placeholder, with a responsive wrapper (100% width, height from the “Height” field, 400px by default).


The [[!Gallery3xEmbeds]] snippet

Its main job is to get all active embeds of the given resource, sort them and pass them to chunks for rendering.

ParameterDefaultDescription
&resourcecurrent resource IDResource to output embeds from. Used if &parents and &resources are not set.
&parentsnullParent resource IDs, comma-separated. Selects embeds from them and all their children. 0 — from the whole site.
&resourcesnullResource IDs, comma-separated. An ID with a minus (-) excludes the resource. Takes priority over &parents.
&tplOutertpl.Gallery3x.Embed.outerWrapper chunk for the whole list.
&tplItemtpl.Gallery3x.Embed.itemChunk for one item (ignored in Fenom mode).
&fenom0If 1 and pdoTools is installed — Fenom mode. &tplItem is not used, and &tplOuter receives the {$embeds} array to process in {foreach}.
&group''Filter by group (several, comma-separated).
&limit0Limit. 0 — no limit.
&offset0Offset (for pagination).
&sortbypositionSort field.
&sortdirASCSort direction (ASC or DESC).
&showInactive0If 1 — embeds disabled in the manager are output too.
&where''JSON string with extra selection conditions.
&debug0If 1 — the prepared data array is shown instead of the output.
&source—Media source for thumbnail URLs (ID or name). Empty — the record's source.

Available placeholders

In the wrapper (&tplOuter): [[+items]] — all embeds rendered with &tplItem; [[+total]] — the count; [[+first.title]] etc. — fields of the first one. In Fenom — {$embeds}, {$total}, {$first}.

The snippet passes all fields of the embed record to the chunk. The main one is [[+embed_html]] (HTML ready for output).

  • [[+embed_html]] — ready HTML of the embed with a responsive wrapper (this is what you output).

  • [[+id]] — record ID.

  • [[+title]] — title.

  • [[+description]] — description.

  • [[+mode]] — mode: url or code.

  • [[+url]] — source link (“Link” mode).

  • [[+code]] — embed code (“Embed code” mode).

  • [[+provider]] — provider (yandex_map, google_map).

  • [[+embed_id]] — the final iframe src (“Link” mode).

  • [[+height]] — height in px (empty = 400).

  • [[+thumbnail_url]] — thumbnail URL (if set).

  • [[+group]] — groups (separated by ||).

  • [[+position]], [[+active]], [[+special]] — position, active flag, “special”.

  • [[+extra_text]], [[+extra_text2]], [[+extra_num]], [[+extra_date]] — extra fields.

Examples

[[!Gallery3xEmbeds]]

Output all embeds of the current resource.

[[!Gallery3xEmbeds?
  &group=`maps`]]

Only embeds from the maps group.

[[!Gallery3xEmbeds? &resource=`15`
  &limit=`3`]]

Three embeds from resource #15.

[[!Gallery3xEmbeds? &fenom=`1` &tplOuter=`
  tpl.Gallery3x.Embed.outer.fenom`]]

Fenom mode — processing the {$embeds} array in a loop inside the wrapper chunk.

[[!Gallery3xEmbeds? &debug=`1`]]

Debugging — shows all prepared data.