heimrichhannot / contao-replace-bundle
Helper contao bundle to perform a regular expression search and replace on front end page.
Installs: 957
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 5
Forks: 0
Open Issues: 1
Type:contao-bundle
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.13 || ^5.0
- heimrichhannot/contao-multi-column-editor-bundle: ^1.2 || ^2.4
- symfony/dependency-injection: ^4.4 || ^5.4 || ^6.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- contao/test-case: ^1.1
- friendsofphp/php-cs-fixer: ^2.2
- php-coveralls/php-coveralls: ^2.0
- php-http/guzzle6-adapter: ^1.1
- php-http/message-factory: ^1.0.2
- phpunit/phpunit: >=6.0 <6.5
- symfony/phpunit-bridge: ^3.2
README
Helper contao bundle to perform a regular expression search and replace on front end page.
Configuration
Currently it is only possible to search and replace globally. Open your contao settings and configure custom search and replace patterns.
Examples
Wrap headline text in <span>
Before: <h1>Test A</h1>
After: <h1><span>Test A<span></h1>
- Pattern:
(<h\d[^>]*>)(.*)(<\/h[^>]*>)
- Replacement:
$1<span>$2</span>$3
Bootstrap 4 responsive tables
Before: <table><thead><tr><th>Value</th></tr></thead><tbody><tr><td>1</td></tr></tbody></table></body></html>
After: <div class="table-responsive"><table class="table table-bordered table-hover"><thead><tr><th>Value</th></tr></thead><tbody><tr><td>1</td></tr></tbody></table></div>
- Pattern:
(<table>)(.*)(<\/table>)
- Replacement:
<div class="table-responsive"><table class="table table-bordered table-hover">$2</table></div>
Replace files path inside links
Before: <a href="tl_files/subfolder/files/file.pdf">Test link</a>
After: <a href="files/backup/file.pdf">Test link</a>
- Pattern:
(tl_files\/subfolder\/files\/)
- Replacement:
<div class="table-responsive"><table class="table table-bordered table-hover">$2</table></div>
- Replace tags: true (checked)