OctoberCMS RESTful API plugins

API Generator

Generates RESTful APIs using available models

RESTful API

RESTful API (WebService) for Import/Export Operations with Extended Features

RESTful

Create RESTful APIs with ease

You can start building your custom REST API based on these plugins.

Frontend User Roles Manager Bugs fixes – for OctoberCMS Shahiem Seymor

http://octobercms.com/index.php/plugin/shahiemseymor-roles

Error: Trigger action is not specified

Fix Error: Trigger action is not specified as per https://github.com/octobercms/october/issues/1543
_list_toolbar.htm
data-trigger-action="enable"
the above need to be added to the button

Yaml / configuration file not found error

Found some bugs in:

  1. /plugins/shahiemseymor/roles/controllers/groups/config_form.yaml
  2. /plugins/shahiemseymor/roles/controllers/groups/config_list.yaml
  3. /plugins/shahiemseymor/roles/controllers/permissions/config_form.yaml
  4. /plugins/shahiemseymor/roles/controllers/permissions/config_list.yaml

Instead of full paths to the config files with ~ or code>@ you can change it to $/shahiemseymor/roles/controllers/groups/config_form.yaml etc. In the last builds (347, 348) of October I'm getting errors because you used code>@ in /plugins/shahiemseymor/roles/controllers/groups/config_list.yaml

 

Markup accessing page parameters as object or array for OctoberCMS

You can access the current URL parameters via this.param and it returns a PHP array.

Accessing page parameters

This example demonstrates how to access the tab URL parameter in a page.

url = "/account/:tab"
==
{% if this.param.tab == 'details' %}

    

Here are all your details

{% elseif this.param.tab == 'history' %}

You are viewing a blast from the past

{% endif %}

If the parameter name is also a variable, then array syntax can be used.

url = "/account/:post_id"
==
{% set name = 'post_id' %}

The post ID is: {{ this.param[name] }}

reference: https://octobercms.com/docs/markup/this-param

Detect iOS in OctoberCMS to differ the script or other resources loads

in the "code" section of the CMS page editor

put in below codes

function onStart()
{
 //Detect special conditions devices
 $iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
 $iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
 $iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
 $Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
 $webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");

 $this['isIos'] = false;

 //do something with this information
 if( $iPod || $iPhone ) {
 //browser reported as an iPhone/iPod touch -- do something here
 $this['isIos']= true;
 } else if($iPad) {
 //browser reported as an iPad -- do something here
 $this['isIos']= true;
 } else if($Android) {
 //browser reported as an Android device -- do something here
 $this['isIos']= false;
 } else if($webOS) {
 //browser reported as a webOS device -- do something here
 $this['isIos']= false;
 }
 //var_dump($this['isIos']);
}

then you can call the isIos variables in html section

{% if isIos %}
{% partial "some-partial-for-ios" %}
{% else %}
{% partial "some-partial-not-for-ios" %}
{% endif %}

reference: http://stackoverflow.com/questions/6322112/check-if-php-page-is-accessed-from-an-ios-device

 

Instant response for OctoberCMS Flash messages combined with Romanov.Flashmessage plugin (no page reload)

$validation = Validator::make($data, $rules);
 if ($validation->fails()) {
     throw new ValidationException($validation);
 }
 try {
     $user = Auth::authenticate([
         'login' => array_get($data, 'login'),
         'password' => array_get($data, 'password')
     ], true);
 }
 catch (Exception $ex) {
     if (preg_match('/user was not found with the given cred/i',$ex->getMessage())) {
     $flash_message = 'A registered user was not found with that email';
 }
 elseif (preg_match('/hashed credential "password" did not match/i',$ex->getMessage())) {
     $flash_message = 'The password supplied for that user is incorrect';
 }
 }
 if ($flash_message) {
     return ['msgs' => [ 'danger' => $flash_message ], 'options' => [], 'settings' => [] ];
 }

 

This will replace the error message " user was found to match all plain text credentials however hashed credential "password" did not match." that comes by default with Laravel.

 

Source:

https://gist.github.com/kdallas/17e07f9b50b066a13bdd#file-account-php-L138

OctoberCMS debugging – DUMP() debug function for templating and Debugbar plugin

This is a very handy function for debugging the template.

reference: https://octobercms.com/docs/markup/function-dump

Usage:

{{ dump(user) }}
{{ dump(user, categories) }}
{{ dump() }}

It'll show you the variable type and its content, eg. if you have an object variable it'll show you the member functions or if you have a collection variable, it'll show you the keys and value types.

The following screenshot indicates the front-end output of an array variable:
octoberCMS dump function debug output screenshot for template front end

Here is another useful OctoberCMS plugin that'll help debugging as it could show much more information in the backend.

OctoberCMS DebugBar plugin

OctoberCMS debugbar plugin on GitHub: https://github.com/Flynsarmy/oc-debugbar-plugin

on OctoberCMS plugins page: https://octobercms.com/plugin/bedard-debugbar