Skip to content

Instantly share code, notes, and snippets.

$category = $imanager->getCategory('slug=my-category-slug');
// or
$category = $imanager->getCategory('name=My Category Name');
// or
$category = $imanager->getCategory('position=2');
// etc
$categoryMapper = $imanager->getCategoryMapper();
@bigin
bigin / 0_reuse_code.js
Created August 16, 2016 08:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<div id="main-wrapper">
<h1>[[page_title]]</h1>
<div class="content-wrapper">
<div class="content">
[[page_content]]
</div>
</div>
<div class="sidebar">
[[page_sidebar]]
</div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>HTML5 template</title>
<link rel="stylesheet" href="<?php get_theme_url(); ?>/css/styles.css">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
html,body {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
font:inherit;
vertical-align:baseline;
}
$item = imanager()->getItemMapper()->init(8, 50);
// Accessing a field value
echo $item->fields->fieldname->value;
$item = imanager()->getItemMapper()->init(8, 50);
// Accessing an item attribute
echo $item->name;
<?php
/**
* Class ItemSimplificator, just a simple decorator class
*/
class ItemSimplificator
{
protected $_item;
public function __construct(Item $item) {
$this->_item = $item;
// get an item with the id 50 of the category 8
$item = imanager()->getItemMapper()->init(8, 50);
// simplify item
$item = new ItemSimplificator($item);