定制 theorythree/navprompt 二次开发

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

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

theorythree/navprompt

Composer 安装命令:

composer require theorythree/navprompt

包简介

An easy-to-use navigation helper for your Laravel projects.

README 文档

README

Latest Version on Packagist Software License Build Status Total Downloads

Description

A simple solution for a simple problem. This package marks HTML elements with a CSS is-active class based on the current URI. Although this package was originally conceived to be used on navigation, it can be used anywhere you need to mark elements with an active class name.

How to Install

Step 1: Via Composer

$ composer require theorythree/navprompt

Step 2: Define the service provider and alias in your Laravel project

This package takes advantage of the new auto-discovery feature found in Laravel 5.5+. If you're using that version of Laravel, then you may skip this step.

Add NavPrompt Service Provider to config/app.php.

'providers' => [

  /*
   * Application Service Providers...
   */

  TheoryThree\NavPrompt\NavPromptServiceProvider::class,
];

Define the NavPrompt Alias to config/app.php.

'aliases' => [

  /*
   * Aliases
   */
  'Nav' => TheoryThree\NavPrompt\NavPromptFacade::class,
];

Step 3. Publish the plugin config file (Optional)

Publish the configuration file to override the package defaults. The package is setup by default to work with Bulma - which uses an active class name of is-active, however if your project is using Bootstrap, you'll want to override the default active class name to active. To do this, publish the config file used by this plugin and set the override for the active_class value to active.

$ php artisan vendor:publish --tag=navprompt This command will generate a config file in config/navprompt.php.

return [

    'active_class' => 'is-active',  // change to 'active' for Bootstrap
];

Usage

This package uses the alias Nav:: to access the plugin class in your project template files. You can use any of the following methods to check your routes against:

  1. routeIsNamed() // checks URI against Laravel named route
  2. routeIs() // checks URI against full URI provided
  3. routeContains() // checks URI to see if it contains provided slug

routeIsNamed()

String routeIsNamed( String $route, String $active=NULL )

Description

Accepts a string of the desired Laravel named route for NavPrompt to check against and returns an empty string (no match) or a string containing the name of the active class (match).

Parameters

$route

String: The Laravel route name to test against

$active

String | NULL (OPTIONAL): The name of the CSS class that should be returned if a URI match occurs

Example

// Route 1: Route::get('/about', 'AboutController@index')->name('about');
// Current URL: http://www.mycompany.com/about

<a href="/about" class="{{ Nav::routeIsNamed('about') }}">About Us</a>
// returns 'is-active' string

// result:
<a href="/about" class="is-active">About Us</a>

routeIs()

String routeIs( String $route, String $active=NULL )

Description

This method is designed to be used in cases when testing the full URI path is needed. For example, if you have several, similar links that you need to test.

Accepts a string of the full URI for NavPrompt to check against and returns an empty string (no match) or a string containing the name of the active class (match). This method is designed to be used in cases where

Parameters

$route

String: The full URI route to test against

$active

String | NULL (OPTIONAL): The name of the CSS class that should be returned if a URI match occurs

Example

// Current URL: http://www.mycompany.com/about/team/dan-merfeld/

<a href="/about/team/dan" class="{{ Nav::routeIs('/about/team/dan') }}">About Dan</a>
// returns 'is-active' string

// result:
<a href="/about/team/dan" class="is-active">About Dan</a>

routeContains()

String routeContains( String|Array $slugs, Int|Array $positions, String $active=NULL )

Description

This method is designed to be used in cases when you need to check for the existence of a specific URI slug within the full URI path.

Accepts a string (or array of strings) of the URI slug(s), and an optional position integer (or array of integers), for NavPrompt to check against and returns an empty string (no match) or a string containing the name of the active class (match). This method is designed to be used in cases where

Parameters

$slugs

String|Array: The URI slug(s) to test against

$positions

Int | Array (OPTIONAL): The position(s) of the URI slug in relation to the full URI.

$active

String | NULL (OPTIONAL): The name of the CSS class that should be returned if a URI match occurs

Example

Basic Example:

// Current URL: http://www.mycompany.com/about/team/dan/

<a href="/about/team/dan" class="{{ Nav::routeContains('team') }}">About Dan</a>
// returns 'is-active' string

// result:
<a href="/about/team/dan" class="is-active">About Dan</a>

Basic Position Example:

// Current URL: http://www.mycompany.com/about/team/dan/

// position 1 = "about"
// position 2 = "team"
// position 3 = "dan"

<a href="/about/team/dan" class="{{ Nav::routeContains('team',1) }}">About Dan</a>
// returns '' string

// result:
<a href="/about/team/dan" class="">About Dan</a>

Advanced Position Example:

// Current URL: http://www.mycompany.com/sports/contact/football/

// position 1 = "sports"
// position 2 = "contact"
// position 3 = "football"

<a href="/contact" class="{{ Nav::routeContains('contact',1) }}">Contact Us</a>
// returns '' string
// Result: <a href="/contact" class="">Contact Us</a>

<a href="/sports/contact" class="{{ Nav::routeContains('sports',[1,2]) }}">List all Contact Sports</a>
// returns 'is_active' string
// Result: <a href="/sports/contact" class="is_active">List all Contact Sports</a>

<a href="/contact/sports" class="{{ Nav::routeContains('sports',[1,2]) }}">List all Contact Sports</a>
// returns 'is_active' string
// Result: <a href="/contact/sports" class="is_active">List all Contact Sports</a>

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

All contributors welcome. If you would like to contribute to this package please feel to submit a pull request, submit an issue, or request a feature.

See our CONTRIBUTING and CODE_OF_CONDUCT for more details.

Credits

Contact

Want to get in touch to discuss this package, or another one you'd like us to build? Feel free to reach out to the maintainer of this package by emailing me at dan@theorythree.com, follow or @ me on Twitter @dmerfeld. I'd really like to hear from you. Honest.

License

The MIT License (MIT). Please see License File for more information.

theorythree/navprompt 适用场景与选型建议

theorythree/navprompt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 01 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「TheoryThree」 「NavPrompt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 theorythree/navprompt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 theorythree/navprompt 我们能提供哪些服务?
定制开发 / 二次开发

基于 theorythree/navprompt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

与 theorythree/navprompt 相关的其它包

同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-06