This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Laravel has some date functions in the query builder that I never really | |
// see mentioned. Most of the time when a user needs to do a MONTH(col) select, | |
// they are advised to do something like this: | |
$employees = Employee::where(DB::Raw('MONTH(hired_at)'), '=', 4)->get(); | |
// However, Laravel seems to have query builder functions that take care of this. | |
// The above query could be rewritten as: | |
$employees = Employee::whereMonth('hired_at', '=', 4)->get(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am adamfairholm on github. | |
* I am adamfairholm (https://keybase.io/adamfairholm) on keybase. | |
* I have a public key whose fingerprint is 37ED C3E3 611C E8F4 D0C3 6EEF 6C70 60D0 61B3 C170 | |
To claim this, I am signing this object: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the streams/plugin.php file, find this line in the form() function (around line 760): | |
if ($recaptcha) | |
Under that, you should see: | |
$this->recaptcha->_rConfig['theme'] = $this->streams_attribute('recaptcha_theme', 'red'); | |
Just above that line, add: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ query:run select="DISTINCT nominee_state" from="nominees" }} | |
<h1>{{nominee_state}}</h1> | |
{{ streams:cycle stream="nominees" include=nominee_state include_by="nominee_state" }} | |
<h3>{{nominee_name}}</h3> | |
{{ /streams:cycle }} | |
{{ /query:run }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ query:run select="DISTINCT nominee_year" from="nominees" }} | |
<option value="{{ nominee_year }}"> | |
{{ nominee_year }} | |
</option> | |
{{ /query:run }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function add_field_to_stream($field_id, $stream_id, $data, $create_column = true) | |
{ | |
// ------------------------------------- | |
// Get the field data | |
// ------------------------------------- | |
$field = $this->fields_m->get_field($field_id); | |
if ( ! $field) { | |
die('no field'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can specify two new things in streams for PyroCMS 2.2.1: | |
// 1. pag_uri_method - Set it to 'query_string', so you can do /my-uri?page=2. Defaults to segment - /my-uri/2. | |
// 2. pag_method - Allows you to set if the value in the URI should be the offset or the page number. | |
{{ streams:sample paginate="yes" pag_uri_method="query_string" pag_method="page" }} | |
<p>{{ var }}</p> | |
{{ /streams:sample }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ streams:cycle stream="example" where="`category_field_slug`='[segment_2]'" }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function lang_var() | |
{ | |
$vars = $this->load->get_vars(); | |
$var = $this->attribute('var'); | |
// Do we have our page | |
if (isset($vars['page'])) { | |
$page = $vars['page']; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------- | |
// Keep Vars | |
// ------------------------------------- | |
// Allow vars to pass through by doing | |
// keep:{var_name}={var_value} | |
// ------------------------------------- | |
$keepers = array(); | |
foreach ($this->attributes() as $key => $val) |
NewerOlder