Giter VIP home page Giter VIP logo

api's Introduction

#SamsonCMS API module

Latest Stable Version Build Status Code Coverage Scrutinizer Code Quality Total Downloads Stories in Ready

SamsonCMS API for interaction with materials, fields and structures.

##Additional fields table After creating corresponding Table structure and setting its Additional fields you can get additional fields table object(\samsoncms\api\field\Table) ancestor for a specific \samsoncms\api\Material ancestor you need to create class that extends generated additional fields table:

class MyTable extends \samsoncms\api\MyGeneratedTable
{
    protected $indexView = 'specify a path to index view file';
    protected $rowView = 'specify a path to row view file';
}

// Creating an instance, with QueryInterface, ViewInterface and Entity identifier
$table = new MyTable($query, $this, $material->MaterialID)

This class will contain generated generic methods for retrieving collection of table column values with according field name, for example if you have additional field with name age method age() would be generated to get collection of age values in all table rows.

###Rendering custom additional field tables SamsonCMS will generate all created Table structure automatically to simplify your code creation, the only thing that needs to be done is extending this generated classes and creating a views for outputting.

Remember \samsoncms\api\field\Table is dependent on \samsonframework\core\ViewInterface instance and uses it for rendering its views, so the path to views and views themselves should be located within this instance.

###Default index view file By default index view renders all rendered rows into view variable with name stored in \samsoncms\api\field\Table::ROWS_VIEW_VAR - rows:

<div class='my-table'>
    <h2>Table title<h2>
    <div class="my-table-rows">
        <?php echo $rows ?>
    </div>
</div>

###Default row view file By default \samsoncms\api\field\Row ancestor view object is stored in \samsoncms\api\field\Table::ROW_VIEW_VAR - row:

<?php /** @var \myapplication\MyTableRow $row */?>
<div class="my-row">
    <div class="name"><?php echo $row->field1 ?></div>
    <div class="name"><?php echo $row->field2 ?></div>
    <div class="name"><?php echo $row->field3 ?></div>
</div>

Give a type hint to a generated \samsoncms\api\field\Row ancestor and IDE will help outputting needed row data.

#Navigation

#Material

Added method for creating/updating material additional fields public function setFieldByID($fieldID, $value, $locale = DEFAULT_LOCALE) Method find Field record in database by Field identifier and the receives its type for correct storing of additional field value.

#Field You can find additional field samsonframework\orm\RecordInterface object by using one of provided methods:

  • By its identifier \samsoncms\api\Field::byID($query, $identifier, &$return = null)
  • By its name \samsoncms\api\Field::byName($query, $name, &$return = null)
  • By its name or identifier \samsoncms\api\Field::byNameOrID($query, $identifier, &$return = null)

All this methods requires first argument samsonframework\orm\QueryInterface instance for performing database queries.

Regular usage example:

/** @var \samsoncms\api\Field $fieldRecord Try to find additional field record */
$fieldRecord = \samsoncms\api\Field::byNameOrID('image')
if (isset($fieldRecord)) {
    // Additional field has been found
}

Last argument is optional and should be used for simple and beautiful condition creation:

/** @var \samsoncms\api\Field $fieldRecord Try to find additional field record */
if (\samsoncms\api\Field::byNameOrID('image', $fieldRecord)) {
    // Additional field has been found
}

#Field value

api's People

Contributors

vitalyiegorov avatar rmolodyko avatar nik-os avatar getmanenko avatar expenect avatar scrutinizer-auto-fixer avatar onysko avatar

Watchers

James Cloos avatar Vadim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.