Skip to content

Instantly share code, notes, and snippets.

// CONTROLLER: Stores retrieved product fields into a F3 array variable 'products';
public function index()
{
$this->f3->set('products', $this->db->exec("SELECT * FROM products LIMIT 5"));
$this->f3->set("page_title", "Homepage");
$this->f3->set("page_id", "home");
$this->f3->set('view','app/views/user/home.htm');
}
@sajadtorkamani
sajadtorkamani / gist:ba3bd4f58e00eae04f0a
Last active August 29, 2015 14:20
Getting position of occurrences of a guessed letter in a given word (Hangman).
$(document).ready(function() {
function getChar(string, position)
{
var char = string.charAt(position);
console.log(char);
}
function getPositions(correctWord, guess)
// Vertically enter an element of unknown height
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
transform: translateY(-50%);
}
// Vertically and horizontally align child element in parent element
img {
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
<?php
$item = $this->view;
$banner_img = $item->images('banner_img');
// $client = $item->links("clients", array('single'=>true));
// $client_logo = $client->images('thumbnail', true);
?>
<div class="case-study-banner">
<?php
$item = $this->view;
$casestudy = $item->links("case_studies_featured", array('single'=>true));
$banner_img = $casestudy->images('banner_img');
$client = $casestudy->links("clients", array('single'=>true));
$client_logo = $client->images('alt_logo', true);
@sajadtorkamani
sajadtorkamani / gist:4b629816a384a5a0fd3f
Created June 1, 2015 16:31
Linking to videos example
<?php
/**
* Module Title
*
* Module description
*
* @author Andrew Womersley
* @category Module
* @package STAN
<div class='container'>
<?php Module(788); ?>
</div>
<?php Module(3446); ?>
<div class="service-intro">
<?php Module(3437); ?>
<?php Module(3440); ?>
</div>
<?php
function beautifyString($string)
{
$beautifiedString = strtr($string, array('-' => ' '));
$beautifiedString = ucwords($beautifiedString);
return $beautifiedString;
}
?>
@sajadtorkamani
sajadtorkamani / gist:0d88428d529c1216c922
Created June 4, 2015 13:46
Retrieving params from a database
$params = array('database'=>'partners');
$search = Search()->setParams($params);
$partners = $search->get();