Download the PHP package numencode/wn-fundamentals-plugin without Composer

On this page you can find all versions of the php package numencode/wn-fundamentals-plugin. 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 wn-fundamentals-plugin

Fundamentals Plugin

The Fundamentals Plugin is a toolbox for Winter CMS projects: inline editing of related records with a relation repeater, publishable models, theme-overridable component layouts, small backend improvements, Twig functions and PHP helpers. It is also the foundation of the other NumenCode plugins.

Version Packagist PHP Version Support Tests License


Features

Requirements

Installation

The plugin has no database tables, so no migrations are needed.

Configuration

The plugin makes a few changes to the whole backend. Each one is enabled by default and can be switched off by creating config/numencode/fundamentals/config.php in your project:

Option What it does
switch_column_icons List columns of type switch show a green check or a red cross with the translated Yes/No label.
pages_viewbag_primary_tabs Winter.Pages: the page settings (viewBag fields) are shown in the primary tabs instead of the sidebar.
assets Loads the plugin's backend JS and CSS on every backend page. Required for dynamic section titles and the Translate language selector.

Relation repeater

Edit a model's "has many" related records directly in its form, as repeater items. Each item is a real related record: it is created, updated, reordered and deleted together with the parent model, its own validation rules apply, and its translatable fields can be translated.

1. Parent model – implement the behavior and map a form field to the relation:

2. Form field – use the relationrepeater widget with the related model's fields:

All options of the core repeater widget work (titleFrom, style, minItems, maxItems, sortable, ...). showToggleAll: true adds "Expand all" and "Collapse all" buttons above the items. They are shown in list mode with the default or collapsed style, not with accordion (where only one item is open) or in grid mode. The related model's fields.yaml must contain its primary key as a hidden field. Without it, existing items are not recognized, and every save deletes and recreates all related records:

How saving works

Winter.Translate integration

When Winter.Translate is installed:

Without Translate, the plugin works the same, without these features.

Publishable models

Hide unpublished records on the frontend. Logged-in backend users still see them, so they can preview content before publishing it; the backend and console commands are not affected.

The model needs a boolean is_published column. To use another column, define a constant:

Component layouts

The ComponentRenderer trait lets editors choose a layout (partial) for a component in the CMS, and lets themes override and add layouts.

Layout selection is enabled per component class, e.g. in your theme plugin's boot() method:

In a page or layout:

renders themes/<theme>/partials/gallery/homepage.htm.

The trait implements the component's onRender() method, so the component must not define its own.

CMS permissions

Revoke backend actions on a controller for backend user groups (by group code):

Check them in the controller or its views:

Available: canCreate, canUpdate, canDelete, canDuplicate and revokeCreate, revokeUpdate, revokeDelete, revokeDuplicate. A user is denied an action when any of their groups has it revoked.

Config overrides

Change the YAML configuration of other plugins and modules from code, without copying their files:

Method Config file
extendFields($class, $callback) fields.yaml
extendColumns($class, $callback) columns.yaml
extendImportColumns($class, $callback) columns_import.yaml
extendExportColumns($class, $callback) columns_export.yaml
extendImportExport($class, $callback) config_import_export.yaml
extend($file, $class, $callback) any file in the class's config folder
extendAll($callback) every config file; the callback receives ($publicPath, $config)

The callback receives the configuration as an array and returns the changed array (or null to leave it unchanged).

Twig filters and functions

Name Type Description
resize_images filter Replaces media library images with a pixel width (style="width: 300px" or width="300") in HTML content with a resized copy made by Winter's image resizer: {{ content\|resize_images\|raw }}
url_path filter Path of a URL: {{ 'https://example.com/a/b?c=1'\|url_path }} → /a/b
asset_hash(path) function Cache-busting token. With a path (relative to the theme or the project, or a URL), a short hash that changes when the file changes: {{ 'assets/css/app.css'\|theme }}?v={{ asset_hash('assets/css/app.css') }}. Without a path, a token that changes when the cache is cleared.
device_type() function mobile, tablet or desktop, based on the user agent
detect() function The request's MobileDetect instance: {% if detect().isiOS() %}
collect(items) function A Laravel collection: {{ collect(items).sortBy('title').pluck('title').implode(', ') }}
class_basename(class) function Class name without the namespace
d(...), dd(...) function Dump (and die) – only when app.debug is enabled, otherwise they do nothing

device_type() and detect() read the user agent. With full-page caching or a CDN, the cached HTML is served to every device – prefer responsive CSS where possible.

For images in your own templates, use Winter's built-in |resize filter: {{ image|media|resize(700, 400, {mode: 'crop'}) }}.

PHP helpers

Helper Description
plugin_exists('Winter.Translate') Whether a plugin is installed and enabled
extend_class(Post::class, Behavior::class) Extends an extendable class (model, controller, ...) with a behavior
array_insert($array, $before, $data) Inserts $data before a key (string) or position (int); appends when the key doesn't exist
array_before($array, $needle, $move) Moves the element with key $move directly before the element with key $needle
array_search_recursive($needle, $array) Path of keys to a value in a multidimensional array, e.g. ['fields', 'title', 'label']
dd_query($count = 1) Dumps the executed SQL queries with their bindings and dies after the $count-th one
ddd(...) dd() with HTTP status 500, easy to spot in the browser's network tab (AJAX debugging)
ddt($skip = 0, $die = true) Prints a simple backtrace (file : line – function)

Backend improvements

Common translations

Labels used across NumenCode plugins, for reuse in your own fields.yaml and columns.yaml:

Groups: field.* (id, title, subtitle, description, content, picture, link, slug, sort order, ...), timestamp.* (created, updated, deleted, ...) and item.* (item labels and actions). See lang/en/lang.php.

The plugin is translated into English and Slovenian (lang/sl).

Upgrading from 1.x

Version 2.0 removes several features and changes some APIs. See the upgrade guide in the CHANGELOG.

Changelog

All notable changes are documented in the CHANGELOG.

Contributing

Please refer to the CONTRIBUTING guide for details on contributing to this project.

Security

If you discover a security issue, please email [email protected] instead of using the issue tracker.

Author

The NumenCode.Fundamentals plugin is created and maintained by Blaz Orazem. More NumenCode plugins: numencode.com.

For inquiries, contact: [email protected]

License

This project is open-sourced software licensed under the MIT license.


All versions of wn-fundamentals-plugin with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
composer/installers Version ^1.0 || ^2.0
mobiledetect/mobiledetectlib Version ^4.8
winter/storm Version ^1.2
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 numencode/wn-fundamentals-plugin contains the following files

Loading the files please wait ...