Releases: webitproff/telegram-market-cotonti
Release list
Version=4.1.3 Final Jun 2Th, 2026
tgm4market Plugin: Integrating Your Cotonti Shop with Telegram
Complete Guide to Installation, Setup, and Usage
Author: webitproff
Repository: https://github.com/webitproff/telegram-market-cotonti
Table of Contents
- Introduction
- Key Features
- Architecture and File Structure
- Plugin Installation
- Telegram Setup
- Configuring the Plugin via the Cotonti Admin Panel
- Placing Tags in Templates
- How the Plugin Works: Adding, Editing, and Deleting Products
- Discussion Widget on the Product Page
- Storage of Settings and Data
- Step-by-Step Usage Scenario
- Repository and Support
- Conclusion
Introduction
tgm4market is a plugin for the Cotonti CMF that fully integrates your online store (built with the Market module) with the Telegram messenger. It automatically publishes information about new and updated products to your Telegram channel and embeds the official Telegram Discussion widget on each product page. This allows your subscribers to instantly learn about new items, and visitors to view and leave comments (via Telegram) right from the product card.
The plugin eliminates manual posting and on‑site comment moderation: everything happens automatically, while discussions stay in the familiar Telegram environment.
Key Features
- Automatic publishing when a new product is created: a message with the product name and a link to the website is sent to the Telegram channel.
- Flexible control when editing a product: you can choose whether to create a new post, update the existing one, or do nothing.
- Official Telegram Discussion widget is embedded into the product page using a special tag. Comments on the channel post are displayed directly on the site.
- Link removal when a product is deleted: the record linking the product and the Telegram message is deleted from the database (the message itself remains in the channel).
- Independent configuration via a convenient admin panel: the bot token and channel data are stored in a dedicated database table, not hard‑coded in the code.
- Russian and English language support in the plugin interface.
- Security: built‑in input sanitization, using
htmlspecialcharsto prevent XSS attacks.
Architecture and File Structure
The plugin consists of several hook files that connect to events of the Market module and extend its functionality. Settings are stored in a separate database table, and the administrative interface is implemented as a tool in the “Tools” section.
The plugin folder structure (plugins/tgm4market/):
tgm4market/
├── tgm4market.setup.php // Plugin header and registration
├── tgm4market.admin.php // Settings page controller
├── tgm4market.admin.tpl // Settings form template
├── tgm4market.global.php // Global hook file (loads language strings)
├── tgm4market.market.add.add.done.php // Handler after a product is added
├── tgm4market.market.add.tags.php // Tags hook: adds radio buttons to the add form
├── tgm4market.market.edit.update.done.php // Handler after a product is updated
├── tgm4market.market.edit.delete.done.php // Handler after a product is deleted
├── tgm4market.market.edit.tags.php // Tags hook: adds radio buttons to the edit form
├── tgm4market.market.tags.php // Tags hook: generates the discussion widget on the product page
├── inc/
│ └── tgm4market.functions.php // Core functions: send/edit messages, get configuration
├── lang/
│ ├── tgm4market.ru.lang.php // Russian language file
│ └── tgm4market.en.lang.php // English language file
└── setup/
├── tgm4market.install.sql // SQL queries executed on installation
└── tgm4market.uninstall.sql // SQL queries executed on uninstallation
Each file handles a specific part of the logic, making maintenance and modification straightforward.
Plugin Installation
- Copy the
tgm4marketfolder into theplugins/directory of your Cotonti site. - Go to the admin panel, navigate to Extensions → Plugins.
- Find tgm4market in the list and click Install.
- During installation, two database tables are automatically created:
cot_tgm4market– stores the link between a product ID and a Telegram message ID.cot_tgm4market_cfg– stores the settings: bot token and channel usernames.
- During installation, two database tables are automatically created:
- Once successfully installed, the plugin becomes active and you can proceed to configuration.
Telegram Setup
The plugin requires three Telegram entities:
- Bot – will publish messages to the channel.
- Public channel – where the bot posts messages.
- Comment group – discussions happen in a separate group linked to the channel.
Brief instructions:
- Create a bot via @BotFather. Send the
/newbotcommand, set a name and a username ending inbot(e.g.,myshop_bot). Save the obtained token – you'll need it for plugin configuration. - Create a public channel. When creating, choose “Public Channel” and set a username (e.g.,
myshop). The channel link will bet.me/myshop. This username will be used in two forms:- with
@(@myshop) – for sending messages via the bot, - without
@(myshop) – for the discussion widget.
- with
- Create a comment group (any group, can be private). Open the newly created channel, go to Settings → Discussion → Add Group, and select the group.
- Add the bot to both the channel and the group as an administrator. In the channel, grant the “Post Messages” permission. In the group, at least “Read Messages” is sufficient.
A detailed step‑by‑step guide with screenshots (if needed) is available in the plugin documentation in the repository.
Configuring the Plugin via the Cotonti Admin Panel
After installation, go to Tools (in the Cotonti admin panel) and select tgm4market. A settings page will open, reachable at:
admin.php?m=other&p=tgm4market
The form contains three fields:
-
Channel username (without @, for widget)
Enter the username of your public channel without the@symbol. Example:myshop.
This value is used to build the HTML discussion widget on the product page. -
@channel username (for sending messages)
Enter the same username but with@. Example:@myshop.
This value is used when sending messages via the Telegram API (the bot will publish to this channel). -
Bot token
Paste the token obtained from @Botfather. It looks like123456789:ABCdef....
Click Save. All data will be written to the cot_tgm4market_cfg table with cfg_id = 1. The next time you open the settings page, the values will be automatically loaded from the database.
These settings can be changed at any time. The plugin does not store them in Cotonti configuration files, making site migration safer.
Placing Tags in Templates
For the plugin to work, you need to insert special tags into your theme (skin) templates. All tags are generated by the plugin automatically when the necessary settings are present.
1. Tag for the Add Product form
File: skins/your_skin/market.add.tpl
Tag: {TGM4MARKET_ADD_ACTION}
Insert it wherever convenient (e.g., before the “Save” button). It will add a block with radio buttons:
- “Do nothing”
- “Publish as new”
By default, when creating a new product, “Publish as new” is selected – the message will be sent immediately to the channel. You can switch to “Do nothing” to skip publication if needed.
2. Tag for the Edit Product form
File: skins/your_skin/market.edit.tpl
Tag: {TGM4MARKET_EDIT_ACTION}
It adds three radio buttons:
- “Do nothing”
- “Publish as new”
- “Update existing”
By default, “Do nothing” is selected to avoid accidental changes to the Telegram post. The chosen action determines the behavior when saving changes to the product (see below).
3. Tag for the Discussion Widget
File: skins/your_skin/market.tpl (the main product page template)
Tag: {TGM4MARKET_DISCUSSION}
Insert it where you want the discussion block to appear, typically after the product description or in a separate tab. The plugin will automatically load the official Telegram Discussion widget, pointing ...