PHPackages                             prestasafe-smarty-components/core - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. prestasafe-smarty-components/core

ActiveLibrary[Templating &amp; Views](/categories/templating)

prestasafe-smarty-components/core
=================================

Système de composants Smarty inspiré de Vue.js avec AlpineJS, compatible avec PrestaShop

v1.0.3(1y ago)012MITSmartyPHP &gt;=7.2.0

Since Apr 21Pushed 1y ago1 watchersCompare

[ Source](https://github.com/PrestaSafe/prettyblocksComponents)[ Packagist](https://packagist.org/packages/prestasafe-smarty-components/core)[ RSS](/packages/prestasafe-smarty-components-core/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (5)Used By (0)

SmartyComponents
================

[](#smartycomponents)

A component manager for Smarty that simplifies the creation and use of reusable components in your templates, with a modern style using Tailwind CSS v4. Compatible with PrestaShop.

Installation
------------

[](#installation)

1. Install dependencies with Composer:

```
composer require prestasafe-smarty-components/core
```

2. For a standard project:

```
php -S localhost:8000
```

PrestaShop Compatibility
------------------------

[](#prestashop-compatibility)

SmartyComponents is designed to work perfectly with a PrestaShop module. It offers specific features to facilitate integration:

- Support for Smarty 3.1+ (used by PrestaShop 1.7+) and Smarty 4.3+
- Specific factory for PrestaShop modules with automatic path detection
- Basic components compatible with PrestaShop design

### Usage in a PrestaShop module

[](#usage-in-a-prestashop-module)

1. Add the dependency to your module's `composer.json` file:

```
{
    "require": {
        "smarty-components/core": "^1.0"
    }
}
```

2. In your main module file, initialize the component manager with the factory method:

```
// In a hook method or controller
$smarty = $this->context->smarty;
$componentManager = \SmartyComponents\Factory::createForPrestaShop($smarty, $this->name);

// Register the components you want to use
$componentManager->registerCardComponent();
$componentManager->registerSlotComponent();
$componentManager->register('button');
$componentManager->register('alert');
```

3. Create component templates in the `views/templates/components/` folder of your module.
4. Use them in your Smarty templates as in the example below.

Using the SmartyComponentManager
--------------------------------

[](#using-the-smartycomponentmanager)

The `SmartyComponentManager` allows you to easily register Smarty components without having to write a lot of repetitive code.

### Initialization

[](#initialization)

```
// Instantiating Smarty
$smarty = new \Smarty();

// Basic Smarty configuration
// ...

// Initializing the component manager
$componentManager = new \SmartyComponents\SmartyComponentManager($smarty, 'components');

// OR with the Factory
$componentManager = \SmartyComponents\Factory::create($smarty, 'components');

// OR with pre-registered components
$componentManager = \SmartyComponents\Factory::createWithCommonComponents($smarty);
```

### Registering a simple component

[](#registering-a-simple-component)

To register a simple component, just call the `register` method with the component name:

```
// Registers an "alert" component that will use the "components/alert.tpl" template
$componentManager->register('alert');
```

The manager will automatically create a handler that assigns parameters and content to the template and displays the corresponding template.

### Registering a component with a custom handler

[](#registering-a-component-with-a-custom-handler)

If you need custom logic for your component, you can provide your own handler:

```
$componentManager->register('button', function($params, $content, $template, &$repeat) {
    // Your custom logic here
    $template->assign('params', $params);
    $template->assign('content', $content);
    if (!$repeat && $content !== null) {
        return $template->fetch('components/button.tpl');
    }
});
```

### Special components

[](#special-components)

The manager also includes methods to register special components like `card` and `slot` that have particular logic:

```
// Register the "card" component
$componentManager->registerCardComponent();

// Register the "slot" component
$componentManager->registerSlotComponent();
```

Creating component templates with Tailwind CSS v4
-------------------------------------------------

[](#creating-component-templates-with-tailwind-css-v4)

For each component, create a template file in the `components/` folder (or the one specified during initialization) with the name of the component, for example `button.tpl`:

```
{* button.tpl *}

    {$content nofilter}

```

Using components in your templates
----------------------------------

[](#using-components-in-your-templates)

Once registered, you can use your components in your Smarty templates:

```
{button class="bg-green-500 hover:bg-green-600"}Click here{/button}

{alert type="warning"}

        Warning! This is an alert message.

{/alert}

{card}
    {slot name="title"}Card Title{/slot}
    {slot name="card_content"}
        Card content
    {/slot}
{/card}
```

Integrating Tailwind CSS v4
---------------------------

[](#integrating-tailwind-css-v4)

To use Tailwind CSS v4 in your application, simply add the script to your main template:

```

```

All components are already configured to use Tailwind CSS v4, including dark mode support with the `dark:` classes.

Customizing components
----------------------

[](#customizing-components)

You can customize any component by passing additional classes via the `class` parameter:

```
{button class="bg-purple-500 hover:bg-purple-600 w-full"}Full width button{/button}
```

Extending the manager
---------------------

[](#extending-the-manager)

You can extend the `SmartyComponentManager` class to add your own methods for components specific to your application or PrestaShop module.

Examples
--------

[](#examples)

Check the `docs/example-module/` folder for a complete example of usage in a PrestaShop module.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance50

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

383d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4a03cadfb7f4a8dcda4e4fe14fab4d0fbcaec6b920bd6f7bf5ec42bad1d97f31?d=identicon)[PrestaSafe](/maintainers/PrestaSafe)

---

Top Contributors

[![PrestaSafe](https://avatars.githubusercontent.com/u/4788787?v=4)](https://github.com/PrestaSafe "PrestaSafe (11 commits)")

### Embed Badge

![Health badge](/badges/prestasafe-smarty-components-core/health.svg)

```
[![Health](https://phpackages.com/badges/prestasafe-smarty-components-core/health.svg)](https://phpackages.com/packages/prestasafe-smarty-components-core)
```

###  Alternatives

[modx/revolution

MODX Revolution is a Content Management System

1.4k9.1k12](/packages/modx-revolution)[ytake/laravel-smarty

Smarty template engine for Laravel and Lumen

87401.6k](/packages/ytake-laravel-smarty)[noiselabs/smarty-bundle

This Symfony bundle provides integration for the Smarty3 template engine.

53194.4k1](/packages/noiselabs-smarty-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
