Download the PHP package theorythree/navprompt without Composer
On this page you can find all versions of the php package theorythree/navprompt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download theorythree/navprompt
More information about theorythree/navprompt
Files in theorythree/navprompt
Package navprompt
Short Description An easy-to-use navigation helper for your Laravel projects.
License MIT
Homepage https://github.com/TheoryThree/NavPrompt
Informations about the package navprompt
NavPrompt
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
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
.
Define the NavPrompt Alias to config/app.php
.
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
.
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:
- routeIsNamed() // checks URI against Laravel named route
- routeIs() // checks URI against full URI provided
- 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
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
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:
Basic Position Example:
Advanced Position Example:
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 CODE_OF_CONDUCT for more details.
Credits
- Dan Merfeld - Author and Maintainer.
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 @dmerfeld. I'd really like to hear from you. Honest.
License
The MIT License (MIT). Please see License File for more information.