Download the PHP package nightjar/ss-slug without Composer

On this page you can find all versions of the php package nightjar/ss-slug. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ss-slug

ssrigging-slug

Requirements

Please note: For a SilverStripe 3 compatible version, please see the 1.0.0 release.

Installation

  1. composer require nightjar/ss-slug
  2. Apply the extensions as desired
  3. Optionally add configuration
  4. dev/build

Usage

It is best to supply parameters with the extension (though not necessary if the defaults are sufficient, see About:Properties below), so the easiest method of applying it is by definition in the class itself

Or this could happen via _config yaml files

This part is optional, but is a common pattern (and part of this example as a whole). One does not necessarily have to use Page for this, or any kind of 'parent' type model object (as the slug extension at base simply adds a property to a model).

Then comes the much more necessary part where one adds a Controller method to access the items decorated items via a request (provided example here is for a PageController). The controller extension works by providing new url_handlers, directing to an action called handleSlug. One could define a custom handler to deal with this logic, should the need arise.

Note: if your relation is not named Items, but e.g. MyItems, you have to configure SlugHandler in your controller class like:

One can then define a template such as MyVendor/MyNamespace/ItemsPage_handleSlug.ss

About

The holder/child page type pattern is often... potentially unwieldy in large numbers (more than 10). Other modules don't particularly give the flexibility required. ModelAdmin is for managing a type of Model, not for exposing them as pages via a site's front end. Slug provides a much needed a more generic solution, and can be applied easily to multiple objects on a site with minimal fuss. It should even work when they're accessed directly through the a controller, provided one takes care in setting up the configuration.

Properties

The Slug Extension takes three constructor parameters, all of which are optional:

  1. The name of the field it should use to create a slug. (defaults to 'Title')
  2. The name of a relation on the 'parent' object (Page, in the example above), allowing for nested URLs. By default a slug must of course be unique, and this is usually globally to the extended class. However defining a 'parent' allows for a slug to be unique under that parent only. Eg. With the page setup above if ItemsPages were set up to list primary colours, one can have both primary-colours/red AND primary-light-colours/red, rather than primary-light-colours/red1. (defaults to null)
  3. A parity bit. If set to true, whenever the field the module is bound to (Title by default, see 1.) is updated, the slug will automatically update also (keeping parity). Setting this to true also prevents the slug from being manually altered via the CMS by not applying the field to the EditForm. (defaults to false)

The SlugHandler extension takes two constructor parameters, both of which are optional:

  1. The name of the method to get the list of slugged items on. Usually a relationshp name. If set no other relationships will be looked at for slugs (see About:Configuration below), and the slugged items can all be loaded as if they were the action - e.g. some-page/slugged-item. (defaults to null)
  2. The source of data to call methods to fetch slugged item lists from. Controllers do not have relationships to objects, so we must first get one to be able to fetch related items via a slug. e.g. a PageController must first get a Page to be able to source it's data, so too must the SlugHandler find data with this method before dereferencing it. (defaults to 'getFailover')

Configuration

The SlugHandler by default will look for routes by loading the configuration value of slug_trails from either the Controller it is associated with, or the DataObject (or other object - refer to the second constructor parameter explanation above) it leverages to access the list of slugged items. The format of this is ['route-name' => 'RelationshipName', ...] in php, or route-name: RelationshipName in yaml.

With this configuration a route will be valid in the form some-page/route-name/slugged-item, where route-name is always static. This allows one to define routes to multiple relationships on a page instead of just one. To omit this configuration will necessitate the use of the first parameter to the SlugHandler constructor in order to be able to view any items from a request.

Notes


All versions of ss-slug with dependencies

PHP Build Version
Package Version
Requires silverstripe/framework Version ^4||^5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nightjar/ss-slug contains the following files

Loading the files please wait ....