2017 © Pedro Peláez
 

silverstripe-module silverstripe-datapages

Data Pages is a SilverStripe CMS module to create object oriented pages

image

navidonskis/silverstripe-datapages

Data Pages is a SilverStripe CMS module to create object oriented pages

  • Wednesday, August 2, 2017
  • by Doniz
  • Repository
  • 1 Watchers
  • 1 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SilverStripe Data Pages

This is a module (package) as a helper to create linkable data objects with meta tags, url segments, links and more., (*1)

Usage

To create your own linkable object here is an example of simple product object, (*2)

// Product.php
class Product extends DataPage {
    private static $db = []; // your own options
}

// ProductListingPage.php
class ProductListingPage extends Page {

    // list of the products
    public function getProducts() {
        return Product::get();
    }

    // override MetaTags to get from Product
    public function MetaTags($includeTitle = true) {
        $segment = Controller::curr()->getRequest()->param('URLSegment');

        if ($product = Product::getByUrlSegment($segment)) {
            return $product->MetaTags($includeTitle);
        }

        return parent::MetaTags($includeTitle);
    }

}

// ProductListingPage.php
class ProductListingPage_Controller extends Page_Controller {
    private static $allowed_actions = ['product'];
    private static $url_handlers = [
        ''             => 'index',
        '$URLSegment!' => 'product'
    ];

    public function product(SS_HTTPRequest $request) {
        $segment = $request->param('URLSegment');

        if (($product = Product::getByUrlSegment($segment)) && $product instanceof Product && $product->canView()) {
            $this->Title = $product->Title;

            return $this->renderWith(['ProductListingPage_product', 'Page'], [
                'Title'    => $product->Title,
                'Content'  => DBField::create_field('HTMLText', $product->Content),
                'Pictures' => $product->Pictures(),
            ]);
        }

        $this->httpError(404);
    }
}



$Title

$Content

$Title

$Summary
$Form

$Title

$Content

Make object searchable

add this configuration to your config.yml to make DataPage fulltext searchable., (*3)

DataPage:
  indexes:
    SearchFields:
      type: fulltext
      name: SearchFields
      value: '"Title", "Content", "MenuTitle", "MetaDescription", "MetaKeywords"'
  create_table_options:
    MySQLDatabase: 'ENGINE=MyISAM'

The Versions

02/08 2017

dev-master

9999999-dev http://github.com/navidonskis/silverstripe-datapages

Data Pages is a SilverStripe CMS module to create object oriented pages

  Sources   Download

The Requires

 

by Donatas Navidonskis

module cms page silverstripe data dataobjectaspage