定制 fromholdio/silverstripe-relativeurlfield 二次开发

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

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

fromholdio/silverstripe-relativeurlfield

最新稳定版本:2.0.0

Composer 安装命令:

composer require fromholdio/silverstripe-relativeurlfield

包简介

关键字:

README 文档

README

Upgraded for Silverstripe v6.x. See tags/branch 1.x for SS v5.x compatibility.

Similar to SiteTreeURLSegmentField except:

  • No SiteTree dependency - use anywhere
  • Set a BaseURL (or Director::absoluteBaseURL as fallback)
  • User can enter a URL slug - or a full URL path (toggled via field setting)
  • User can include query string or not (toggled via field setting)
  • Based on URL slug (or full path), collision checks are performed, and -n counter added to value
  • By default, using BaseURL and supplied URL slug/path, collision with pages in site tree is checked
  • Base URL is always displayed to user, including when entering relative url path, so that the user sees the context and understands which part of the url they should be entering

Straight-forward to use:

$field = RelativeURLField::create('FieldName', 'Field Title');

// available toggles/settings
$field->setBaseURL();                           // The base URL that the user-entered value is relative to. Defaults to Director::absoluteBaseURL().
$field->setBaseURLBySiteTree();                 // Pass a SiteTree object here, to use it's AbsoluteLink as the BaseURL (useful for Multisites for example, pass the Site object).
$field->setIsQueryStringAllowed();              // Can user include a query string? (will be stripped if not)
$field->setisFullPathAllowed();                 // Can user enter a path with multiple slugs? (else their value will have '/'s removed)
$field->setHelpText();                          // Special chars text

// manage collision checks
$field->addCollisionCheck($key, ?$callable);   // pass a string Key and either implement check via $callable, or use Key via extension hook
$field->removeCollisionCheck($key);            // remove by Key. 'sitetree' is enabled by default.

Couple of screenshots to give the gist

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-01-06