Cartalyst LLC.
Content by Cartalyst
0
22
0
7
1

This package requires a valid subscription. Subscribe for access.

Preface

Introduction

A Platform 9 extension to manage content sections across your application.

Have a read through the Installation Guide.

Features

  • create, update or delete content.
  • assign name & slug.
  • enable/disable.
  • set storage type, either database or filesystem.
  • blade syntax @content('short-name', 'fallback', 'area:theme').
  • nest @content() calls.
  • add tags.
  • add attributes.

Examples

The $content variable used below is a reference to the ContentRepository.

$content = app('platform.content');
Retrieve all content sections.
$allContentSections = $content->findAll();
Dynamically create a new content section.
$content->create([
    'name'       => 'Foo',
    'slug'       => 'foo',
    'enabled'    => true,
    'type'       => 'filesystem',
    'file'       => 'foo.md',
]);

Setup

Installation

The best and easiest way to install the Content extension is with Composer.

Preparation

Open your composer.json file and add the following to the require array:

"platform/content": "^8.0"

Add the following lines after the require array on your composer.json file:

"repositories": [
    {
        "type": "composer",
        "url": "https://packages.cartalyst.com"
    }
]

Note: Make sure that after the required changes your composer.json file is valid by running composer validate.

Install the dependencies

Run Composer to install or update the new requirement.

php composer install

or

php composer update

Now you are able to install the extension through Platform's admin.

Usage

In this section we'll show how you can manage your content sections.

Repository

IoC Binding

The content repository is bound to platform.content and can be resolved out of the IoC Container using that offset.

$content = app('platform.content');

Methods

The repository contains several methods that are used throughout the extension, most common methods are listed below.

For an exhaustive list of available methods, checkout the ContentRepositoryInterface

  • findAll();

Returns a collection of all content sections.

  • find($id);

Returns a content object based on the given id.

  • findBySlug($slug);

Returns a content object based on the given slug.

  • create(array $data);

Creates a new content section.

  • update($id, array $data);

Updates an existing content section.

  • delete($id);

Deletes a content section.

  • enable($id);

Enables a content section.

  • disable($id);

Disables a content section.

You wont find fancy lifestyle graphics and marketing bravado here. Just cold... hard... code...

Code Well, Rock On!
Processing Payment...