Skip to content

Instantly share code, notes, and snippets.

View kristianb21's full-sized avatar

Kristian kristianb21

View GitHub Profile
@kristianb21
kristianb21 / php-d7-create-entity.txt
Created March 10, 2015 14:43
PHP-D7-Create Entity
$entity_type = 'entity_type';
$entity = entity_create($entity_type, array(
'title' => 'Lorem Ipsum',
'type'=>'bunble_type',
// 'field_custom_field' => array(
// 'und' => array('value')
// ),
)
);
$wrapper = entity_metadata_wrapper($entity_type, $entity);
@kristianb21
kristianb21 / D7-PHP-Get-Args.php
Created January 27, 2015 20:23
D7-PHP:drupal get args
$args_not_clean = arg(); //Get Current Args
$args = array();
foreach ($args_not_clean as $value) {
$args[] = check_plain($value); //sanitize URL arguments
}
@kristianb21
kristianb21 / D7-features-creation-order.txt
Last active August 29, 2015 14:11
drupal features setup
Naming Convention:
[theme/site] Feature - TYPE
[theme/site] Feature - Content - TYPE
[theme/site] Feature - ECK - TYPE
Field Bases
Definitions for all fields on the site. All of them. Leave Out ('taxonomy_forums','comment_body','body')
Field Groups
Definitions for all field groups on the site. All of them.
@kristianb21
kristianb21 / wp-php-wptypes-get-parent.php
Created October 8, 2014 14:04
wp wp-types get parent id
$parent = get_post(wpcf_pr_post_get_belongs('child-id','parent'));
@kristianb21
kristianb21 / wp-php-post-relations.php
Last active August 29, 2015 14:07
wp display post relationships
<?php
types_child_posts($post_type, $args)
/*
$post_type – a string with the name of the child items to load. Since a parent may have children of different types, this argument is required.
$arg – optional, with additional query arguments.
For example, to load ‘room’ child items:
*/
$child_posts = types_child_posts('room');
foreach ($child_posts as $child_post) {
echo $child_post->post_title;
@kristianb21
kristianb21 / wp-php-many2many
Created October 8, 2014 11:50
wp wp-types display many to many
$child_posts = types_child_posts('appearance');
foreach ($child_posts as $child_post) {
$band_id = wpcf_pr_post_get_belongs($child_post->ID, 'band');
$band = get_post($band_id);
echo $band->post_title;
}
<?php
switch ($i):
case 0:
echo "i equals 0";
break;
default:
//code here
endswitch;
?>
<?php new dBug ( $post );?>
@kristianb21
kristianb21 / wp-php-get-children.php
Last active August 29, 2015 14:07
PHP:WP-get children
<?php
//get_children()
$args = array(
// number of post to retrieve
'numberposts' => -1,
/*
Pass the ID of a post or Page to get its children.
Pass 0 to get attachments without parent.
Pass null to get any child regardless of parent.
*/
@kristianb21
kristianb21 / css-inline-block.css
Last active August 29, 2015 14:05
CSS: inline-block
display: inline-block;
*display: inline;
*zoom: 1;