Download the PHP package jordanbeattie/craftcms-faker without Composer
On this page you can find all versions of the php package jordanbeattie/craftcms-faker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jordanbeattie/craftcms-faker
More information about jordanbeattie/craftcms-faker
Files in jordanbeattie/craftcms-faker
Package craftcms-faker
Short Description Fake entry fields for CraftCMS
License
Informations about the package craftcms-faker
Craft CMS Faker
Craft CMS Faker provides a handful of models that you can create an instance of in your Twig code to "fake" various components of Craft CMS.
For example, if you're passing an image to a template, you can access the attributes of the "fake" image just as you would with an Asset from Craft CMS.
Installation
To install the plugin, require it as a composer dependancy as follows:
You can then install the plugin via the plugins section of Craft or by running the following command.
Usage
Entry
Designed to fake a CMS entry, the Entry model can accept any attributes and be assigned to the returned model.
To access the attributes passed in, use the get()
function.
Collection
A collection allows you to run the functions all()
, nth()
and first()
on any array. Helpful for looping in your Twig templates
Asset
Designed to mimic an asset from Craft's asset volumes, this can be used in many different ways.
Available attributes
- url
- title
- alt
- kind
- source
- width
- height
- text
- id
- query
Sources
You can select a source to be used when generating default images. You can choose Lorem Picsum (default), Placeholder or Unsplash.
This can either be selected in the CMS Settings and can be set to a ENV variable.
You can also overwrite this setting per image by passing the source
attribute with either picsum
, placeholder
or unsplash
as the value.
Default URL
If no URl is passed to the function, a URL will be created for you using your selected source (see above). If you want an image generated automatically, simply do not include the URL attribute, instead you can optionally pass a height and width.
Sizing
You can pass width
and height
if you require. This is useful for passing images that are later transformed. Both will default to 200.
ID
When using unsplash
, you can pass an id to select a specific image.
Query
When using unsplash
, you can pass a query string to retrieve images related to the query.
Example
Super Table
Designed to mimic Super Table, this is identical to using Collections. Simply pass in an array of data to access. Each array item should be wrapped in curly brackets to mimic a row.
Donkey Tail
Designed to replicate Donkey Tail, you can use this to replicate a DonkeyTail field and pass in your image and pins.
Available attributes
- Image
- Pins
Each of the functions can be combined and used within each other. For example, if you had a collection of assets:
or if you had an asset within a Super Table field
You can even fake entries and assets within a Donkey Tail field.
If not provided in the attributes, the model will automatically assign a title, URL, slug and postDate.
Navigation
Designed to mimic Verbb's navigation plugin, the navigation function will accept an integer for the total amount of items to return and will provide a Collection of items, each with:
- url
- title
- active
- newWindow
- customAttributes
- hasDescendants
- children
If you would like to return multi-level navigation, you can add a true
second parameter. This currently only supports two levels.
Contact
Jordan Beattie
[email protected]
Aberdeen, Scotland