定制 estd/kirby-modify-text 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

estd/kirby-modify-text

最新稳定版本:1.0.0

Composer 安装命令:

composer require estd/kirby-modify-text

包简介

A plugin to add custom attributes (e.g., styles, classes) to Kirby CMS writer blocks.

README 文档

README

A Kirby CMS plugin to modify text blocks with custom attributes, classes, inline styles, or HTML tags, offering more control over text styling.

Installation

Composer

Install the plugin via Composer:

composer require estd/kirby-modify-text

Manual Installation

Download this repository and place it in your site/plugins directory. Make sure the folder is named kirby-modify-text.

Usage

Use kirby-modify-text to modify text block HTML with dynamic attributes, styles, classes, or tag changes. Here’s an example of how to use it:

<?php

// Define custom styles
$styles = [
    'color: red',
    'font-weight: bold'
];

// Apply modifications to the text block
echo $block->text()->modifyTag([
    'styles' => $styles,            // Inline styles as an array
    'class' => 'custom-class',      // Add one or more CSS classes
    'tag' => 'span',                // Change the HTML tag (optional)
    'attributes' => [
        'data-custom' => 'example'  // Add any custom attributes
    ]
])->kt();

?>

Or modify the text block as you need

// Change tag
<?= $block->text()->modifyTag(['tag' => 'h2'])->kt() ?>

// Add styles
<?= $block->text()->modifyTag(['styles' => ['color: blue', 'font-weight: bold']])->kt() ?>

// Add a attribute
<?= $block->text()->modifyTag(['attributes' => ['data-info' => 'example']])->kt() ?>

Options

  • styles: An array of inline CSS styles to add to the tag.
  • class: A string with CSS classes to add. If the tag already has classes, the new ones will be appended.
  • tag: Specify an HTML tag (e.g., h2, span). If omitted, the original tag remains unchanged.
  • attributes: An associative array of additional attributes, such as data-* attributes, that will be added to the tag.

License

MIT License. See the LICENSE file for details.

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-03