{"id":18637964,"url":"https://github.com/imponeer/smarty-includeq","last_synced_at":"2026-01-04T07:15:54.073Z","repository":{"id":38012023,"uuid":"335561621","full_name":"imponeer/smarty-includeq","owner":"imponeer","description":"Rewritten @smarty-php include variant that was invented for use in @XOOPS, but nowadays is used in some other PHP based CMS'es","archived":false,"fork":false,"pushed_at":"2025-02-21T09:34:53.000Z","size":50,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-09T15:08:29.640Z","etag":null,"topics":["composer-library","hacktoberfest","include","smarty","smarty-plugins"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imponeer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-03T08:50:00.000Z","updated_at":"2025-02-21T09:34:54.000Z","dependencies_parsed_at":"2024-05-01T18:06:28.562Z","dependency_job_id":"fd74ce31-6b8a-4a34-ad75-344201c0d886","html_url":"https://github.com/imponeer/smarty-includeq","commit_stats":{"total_commits":22,"total_committers":3,"mean_commits":7.333333333333333,"dds":"0.40909090909090906","last_synced_commit":"69b67bc60f4e1d66f74ed750a9998dcd9137a7f2"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Fsmarty-includeq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Fsmarty-includeq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Fsmarty-includeq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imponeer%2Fsmarty-includeq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imponeer","download_url":"https://codeload.github.com/imponeer/smarty-includeq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248374702,"owners_count":21093372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["composer-library","hacktoberfest","include","smarty","smarty-plugins"],"created_at":"2024-11-07T05:38:28.779Z","updated_at":"2026-01-04T07:15:54.028Z","avatar_url":"https://github.com/imponeer.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](https://img.shields.io/github/license/imponeer/smarty-includeq.svg)](LICENSE) [![GitHub release](https://img.shields.io/github/release/imponeer/smarty-includeq.svg)](https://github.com/imponeer/smarty-includeq/releases) [![PHP](https://img.shields.io/packagist/php-v/imponeer/smarty-includeq.svg)](http://php.net) [![Packagist](https://img.shields.io/packagist/dm/imponeer/smarty-includeq.svg)](https://packagist.org/packages/imponeer/smarty-includeq) [![Smarty version requirement](https://img.shields.io/packagist/dependency-v/imponeer/smarty-includeq/smarty%2Fsmarty)](https://smarty-php.github.io)\n\n# Smarty IncludeQ\n\nThis library provides a rewritten version of the Smarty `{include}` tag variant originally developed for [XOOPS](https://xoops.org) CMS. The `{includeq}` tag offers enhanced template inclusion capabilities and is now used across various PHP-based content management systems, including [ImpressCMS](https://impresscms.org).\n\nThis implementation was created as a clean-room rewrite to avoid GPL licensing constraints while maintaining full compatibility with the original functionality. The plugin extends Smarty's template inclusion system with additional features specifically designed for CMS environments.\n\nFor reference, see the [original XOOPS implementation](https://github.com/XOOPS/XoopsCore25/blob/v2.5.8/htdocs/class/smarty/xoops_plugins/compiler.includeq.php) to understand the historical context and requirements this plugin addresses.\n\n## Installation\n\nTo install and use this package, we recommend to use [Composer](https://getcomposer.org):\n\n```bash\ncomposer require imponeer/smarty-includeq\n```\n\nOtherwise, you need to include manually files from `src/` directory.\n\n## Setup\n\n### Modern Smarty Extension (Recommended)\n\nFor Smarty 5.x, use the modern extension system by adding the extension to your Smarty instance:\n\n```php\n// Create a Smarty instance\n$smarty = new \\Smarty\\Smarty();\n\n// Register the IncludeQ extension\n$smarty-\u003eaddExtension(new \\Imponeer\\Smarty\\Extensions\\IncludeQ\\IncludeQExtension());\n```\n\n### Legacy Plugin Registration\n\nFor compatibility with older Smarty versions or legacy code, you can register the compiler directly:\n\n```php\n$smarty = new \\Smarty();\n$includeqPlugin = new \\Imponeer\\Smarty\\Extensions\\IncludeQ\\IncludeQCompiler();\n$smarty-\u003eregisterPlugin('compiler', 'includeq', [$includeqPlugin, 'compile']);\n```\n\n### Using with Dependency Injection Containers\n\n#### Symfony Container\n\nTo integrate with Symfony, you can leverage autowiring:\n\n```yaml\n# config/services.yaml\nservices:\n    _defaults:\n        autowire: true\n        autoconfigure: true\n\n    # Configure Smarty with the extension\n    \\Smarty\\Smarty:\n        calls:\n            - [addExtension, ['@Imponeer\\Smarty\\Extensions\\IncludeQ\\IncludeQExtension']]\n```\n\n#### PHP-DI Container\n\nWith PHP-DI container:\n\n```php\nuse function DI\\create;\nuse function DI\\get;\n\nreturn [\n    \\Smarty\\Smarty::class =\u003e create()\n        -\u003emethod('addExtension', get(\\Imponeer\\Smarty\\Extensions\\IncludeQ\\IncludeQExtension::class))\n];\n```\n\n#### League Container\n\nIf you're using League Container, you can register the extension like this:\n\n```php\n// Create the container\n$container = new \\League\\Container\\Container();\n\n// Register Smarty with the IncludeQ extension\n$container-\u003eadd(\\Smarty\\Smarty::class, function() {\n    $smarty = new \\Smarty\\Smarty();\n    // Configure Smarty...\n\n    // Create and add the IncludeQ extension\n    $extension = new \\Imponeer\\Smarty\\Extensions\\IncludeQ\\IncludeQExtension();\n    $smarty-\u003eaddExtension($extension);\n\n    return $smarty;\n});\n```\n\nThen in your application code, you can retrieve the Smarty instance:\n\n```php\n// Get the configured Smarty instance\n$smarty = $container-\u003eget(\\Smarty\\Smarty::class);\n```\n\n## Usage\n\nThe `{includeq}` tag provides enhanced template inclusion capabilities with support for variable passing and output assignment.\n\n### Basic Template Inclusion\n\nSimple template inclusion:\n\n```smarty\n{includeq file=\"header.tpl\"}\n```\n\n### Passing Variables to Included Templates\n\nYou can pass variables to the included template:\n\n```smarty\n{includeq file=\"user_profile.tpl\" user_id=123 show_avatar=true}\n```\n\n### Assigning Output to a Variable\n\nCapture the output of the included template into a variable:\n\n```smarty\n{includeq file=\"sidebar.tpl\" assign=\"sidebar_content\"}\n{* Now you can use $sidebar_content variable *}\n\u003cdiv class=\"main-content\"\u003e\n    {$sidebar_content}\n\u003c/div\u003e\n```\n\n### Advanced Examples\n\n**Including with dynamic file names:**\n\n```smarty\n{includeq file=\"modules/{$module_name}/template.tpl\" module_data=$data}\n```\n\n**Conditional inclusion with assignment:**\n\n```smarty\n{if $show_sidebar}\n    {includeq file=\"sidebar.tpl\" assign=\"sidebar\" user=$current_user}\n{/if}\n```\n\n**Including with complex variable passing:**\n\n```smarty\n{includeq file=\"product_list.tpl\"\n          products=$products\n          show_prices=true\n          currency=\"USD\"\n          per_page=20}\n```\n## Development\n\n### Code Quality Tools\n\nThis project uses several tools to ensure code quality:\n\n- **PHPUnit** - For unit testing\n  ```bash\n  composer test\n  ```\n\n- **PHP CodeSniffer** - For coding standards (PSR-12)\n  ```bash\n  composer phpcs    # Check code style\n  composer phpcbf   # Fix code style issues automatically\n  ```\n\n- **PHPStan** - For static analysis\n  ```bash\n  composer phpstan\n  ```\n\n## Documentation\n\nAPI documentation is automatically generated and available in the project's wiki. For more detailed information about the classes and methods, please refer to the [project wiki](https://github.com/imponeer/smarty-includeq/wiki).\n\n## Contributing\n\nContributions are welcome! Here's how you can contribute:\n\n1. Fork the repository\n2. Create a feature branch: `git checkout -b feature-name`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin feature-name`\n5. Submit a pull request\n\nPlease make sure your code follows the PSR-12 coding standard and include tests for any new features or bug fixes.\n\nIf you find a bug or have a feature request, please create an issue in the [issue tracker](https://github.com/imponeer/smarty-includeq/issues).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimponeer%2Fsmarty-includeq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimponeer%2Fsmarty-includeq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimponeer%2Fsmarty-includeq/lists"}