Download the PHP package sgroup/site-module without Composer

On this page you can find all versions of the php package sgroup/site-module. 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 site-module

Site Module

A base module for all S. Group sites, featuring a few helpers and scaffolding.

Offline switch

There's a hard-offline setting that's useful for when taking a staging site offline. It's more heavy-handed than Craft's offline behaviour, as we want to prevent anyone from logging into Craft (to save confusion between environments).

Control it in your general.php config.

Vite & Resources

Adds a @resource alias for use in templates. This will resolve to either @webroot/../resources if the dev server is running, or @webroot/dist if not. The We store our static asset files outside of the webroot.

We also provide a resource() Twig function that does a similar thing, but resolves to your Vite plugin settings. devServerPublic if the dev server is running, or serverPublic if not. In practice this resolves to http://localhost:3000/ and /dist respectively.

Resources in Twig

Through these, you'll be able to refer to resources like JS, CSS, images and fonts - anything in your /resources folder in your templates. For example, a common scenario is wanting to include images in your Twig templates. You can use the following options to acheieve this.

If you need to inline an SVG, it's encouraged to use the svg() Twig function. With this, your only option is to use an alias.

Base module

Yii's modules are pretty slim, and we loose a bunch of boilerplating that Craft plugins get for free. We add this in base/Module. Every Yii module for a project you create should extend this not Yii's module class.

Twig extensions

We provide a good bunch of Twig extensions for better template development.

svgPlaceholder($width, $height = null)

Given a width and height, this will generate a transparent SVG. This is most commonly used for the src attribute of <img> tags when lazyloading. This creates the correct dimensions for the image, while the real image is being lazyloaded. Doing this prevent a noticable "jump" when going from an image on zero dimensions to the proper one.

getFormattedPhone($value)

An opinionated, AU-based phone formatter. Throw it any phone number and it'll internationalize it, deal with spaces and area codes, ready for use in <a href="tel:"

getVideo($asset, $settings = [])

Given an asset, this will render an <iframe> or <video>. This handles both Embedded Asset plugin videos, or real uploaded videos. For any YouTube-based embedded asset, it'll render an <iframe> and embed the video URL.

You can also pass in attributes to be used either in the URL (as URL-encoded params) or in <video> attributes. You can include any attribute, but some worth mentioning:

Option Description
muted Whether the video should be muted.
autoplay Whether the video should autoplay.
controls Whether the video controls should be shown.

getImg($image, $transform = null, $lazyload = false, $attributes = [], $sizes = 'default')

This will return an <img> tag, pre-configured with a bunch of options.

Option Description
image The asset.
transform Either an array (for dynamic transform) or string for the transform.
lazyload Whether the the image should be lazyloaded.
attributes A collection of attributes, added to the <img> element.
sizes An array of valid sizes, used for srcset.

By default, we use srcset to provide ['1x', '1.5x', '2x', '3x'] sizes.

Focal point

If a focal point is defined on the image, it'll be output via inline style rules.

getImgAttr()

This has the same options as getImg() except the $attributes. This will return an object of attributes for you to apply on your own. Ideally, you'd use the {{ attr() }} function.

You'll notice on the instances we're using lazyloading the need to manually include the lazyload class because we're rendering the classes on our own. Alternatively, you could do:

This would combine the img-cover class in the template and the lazyload class from the function.

getBg()

This behaves in almost the exact same manner as getImg() but returns a <div> element.

Focal point

If a focal point is defined on the image, it'll be output via inline style rules.

getBgAttr()

This behaves in almost the exact same manner as getImgAttr(), just with different attributes.


All versions of site-module with dependencies

PHP Build Version
Package Version
Requires craftcms/cms Version ^5.0.0
yiisoft/yii2 Version ^2.0.0
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 sgroup/site-module contains the following files

Loading the files please wait ....