Cinema
-
Adds custom post type called "Reviews" <?php function create_post_type(){ register_post_type('review', array( 'labels'=>array( 'name'=>__('Reviews'), 'singular_name'=>__('Review') ), 'public'=>true, 'has_archive'=>true, 'capabilities'=>array( 'edit_post'=>'edit_review', 'edit_posts'=>'edit_reviews', 'publish_posts'=>'publish_review', 'read_post'=>'read_review', ), ) ); } add_action('init','create_post_type'); ?> Add abilities to "Reviews" post type <?php function add_theme_caps(){ $subscribers=get_role('subscriber'); $subscribers->add_cap('edit_review'); $subscribers->add_cap('edit_reviews'); $subscribers->add_cap('publish_review'); $subscribers->add_cap('read_review'); $admins=get_role('administrator'); $admins->add_cap('edit_review'); $admins->add_cap('edit_reviews'); $admins->add_cap('publish_review'); $admins->add_cap('read_review'); } add_action('admin_init','add_... Code Custom Post Types Wordpress
-
<?php // Adds custom post type for Projects and Services function create_post_type(){ register_post_type('project', array( 'labels' => array( 'name' => __('Projects'), 'singular_name' => __('Project') ), 'taxonomies' => array('category'), 'public' => true, 'has_archive' => true, 'capabilities' => array( 'edit_post' => 'edit_project', 'edit_posts' => 'edit_projects', 'publish_posts' => 'publish_project', 'read_post' => 'read_project', ), 'supports' => array( 'title','editor','thumbnail' ), ) ); register_post_type('service', array( 'labels' => array( 'name' => __('Services'), 'singular_name' => __('Service') ), 'public' => true, 'has_archive' => true, 'capabilities' => array( 'edit_post' => 'edit_service', 'edit_posts' => 'edit_services', 'publish_posts' => 'publish_service', 'read_po... Code Post referencing setup Assign multiple disciplines to a project Wordpress
-
jQuery(window).load(function(){ jQuery('.flexslider').flexslider( { pauseOnHover: true, controlsContainer: ".flex-container", slideshowSpeed: 8000, before: function(slider){ var currentSlide = slider.slides.eq(slider.currentSlide); jQuery(currentSlide).find('.flex-caption').animate({'opacity':'0','right':'30px'},700); }, after: function(slider){ var currentSlide = slider.slides.eq(slider.currentSlide); jQuery(currentSlide).find('.flex-caption').animate({'opacity':'1','right':'0'},700); }, start: function(slider){ var currentSlide = slider.slides.eq(slider.currentSlide); jQuery(currentSlide).find('.flex-caption').animate({'opacity':'1','right':'0'},700); }, } ); } ); .flex-container .flexslider ul.slides li a p.flex-caption{ background-color: rgba(255,255,255,.9); color: rgba(55,55,55,.98); font-size: 20px; position: absolute; bottom: 0; right: 0; right: 30px; left: auto; z-index: ... Code Using jQuery flexslider with animated captions callback JQuery
-
<?php function organic_context_config_page(){ $form = array(); $form['onthisdate_maxdisp'] = array( '#type' => 'textfield', '#title' => t('Maximum number of links'), '#default_value' => variable_get('onthisdate_maxdisp', 3), '#size' => 2, '#maxlength' => 2, '#description' => t("The maximum number of links to display in the block."), '#required' => TRUE, ); return system_settings_form($form); } ?>... Code Reading/setting Drupal config variables Drupal
-
<?php /////////////////// PAGE DEFINITIONS /////////////////// function migrate_groups_menu(){ $menu["migrate_groups"] = array( "title" => "Migrate grps", "description" => "....", "page callback" => "migrate_multigroup_to_collections", "access callback" => TRUE, ); return $menu; } /*function migrate_multigroup_to_collections() { $content_type = 'thing'; $collection_field = 'field_context'; $multigroup_fields = array( 'field_connection', 'field_title_in_context', ); // Get all the nodes that have value in the multigroup. $query = db_select('field_data_' . $multigroup_fields[0]) ->condition('entity_type', 'node') ->condition('bundle', $content_type); $query->addExpression('DISTINCT entity_id', 'nid'); $query->addExpression('revision_id', 'vid'); $nodes_result = $query->execute(); foreach ($nodes_result as $node) { // Construct the legacy multigroup for the node from the individual fields. $multigroup_data = array(); foreach ($multigroup_fields as $fi... Code Migrates multigroups in D6 to field collections in D7 Drupal
-
<?php function loadchildrens($context){ $sql_children = "SELECT node.nid AS nid, node.vid AS node_vid, node.title AS node_title FROM node node LEFT JOIN content_field_connection node_data_field_connection ON node.vid = node_data_field_connection.vid WHERE (node.type in ('category')) AND (node_data_field_connection.field_connection_nid = ".$context.") ORDER BY node_title ASC"; $db_query_children = db_query( $sql_children ); while( $row = db_fetch_array($db_query_children) ){ $context_tree[ $row["nid"] ] = array(); if( $row["nid"] != "517" ) $context_tree[ $row["nid"] ] = loadchildrens( $row["nid"] ); } return $context_tree; } ?> <?php $node = node_load(arg(1)); $spheres_via_path = array(); $sql_spheres_via_project = "SELECT node.title AS node_title, node.nid AS nid, node.type AS node_type FROM {node} node LEFT JOIN {field_data_field_project} field_data_field_project ON node.nid = field_data_field_project.entity_id WHERE (node.type in ('note')) AND (field_data_field_project.field_project_nid = '".arg(1)."')"; $db_query_spheres_via_project ... Code Drupal DB Query to find Children (Recursively) Drupal PHP Template Coding
-
<ul class="item-list"> <?php $terms_nood = taxonomy_node_get_terms_by_vocabulary($node,6); $terms = taxonomy_get_tree(6); foreach($terms as $term){ //$tagged = taxonomy_term_count_nodes($term->tid); if( $term->name == arg(1) || array_key_exists( $term->tid,$terms_nood ) ){ echo("<li class=\"collapsed tag-category-".$popularityCategory."\">"); echo("<a href=\"/visual/".$term->name."\" class=\"active\">".$term->name."</a>"); echo("</li>\n"); } } ?> </ul> <?php if(arg(0)=='node'&&isset($node)){ $vocabularies = taxonomy_get_vocabularies(); foreach( $vocabularies as $vocabulary ){ if( $vocabularies ){ $terms = taxonomy_node_get_terms_by_vocabulary($node,$vocabulary->vid); if( $terms ){ echo('<div>'); $links = array(); echo('<h3>' . $vocabulary->name . '</h3>'); foreach( $terms as $term ){ $term_uri = taxonomy_term_uri($term); $links... Code Similar by Taxonomy Drupal Template Coding
-
<?php $fields = array( 'field_inspirational_imagery' => 'field_images', ); // Loop through each of the fields/tables with the old name and change them foreach($fields as $field_name => $new_field_name) { // First check that field_name exists if(!db_table_exists('field_data_' . $field_name)) { // If we cannot find a data table then just continue. continue; } // Define some things... $data_table_name = 'field_data_' . $field_name; $revision_table_name = 'field_revision_' . $field_name; $field_info = field_info_field($field_name); $storage_details = $field_info['storage']['details']; // The storage for each field has unique configuration. Must follow. foreach($storage_details['sql']['FIELD_LOAD_CURRENT'] as $field) { // Change the field names. foreach($field as $key => $value) { // Rename the field table columns and preserve existing spec. Let // features take care of any configuration changes. $spec = $field_info['columns'][$key]; db_change... Code Rename stuck field names Drupal PHP
-
add line to /etc/hosts 127.0.0.1 amniot.localhost add lines to /etc/apache2/httpd.conf NameVirtualHost 127.0.0.1:80 <VirtualHost amniot.localhost:80> <Directory "/Library/Webserver/Documents_AMNIOT"> Options FollowSymLinks Indexes AllowOverride All Order deny,allow allow from All </Directory> ServerName amniot.localhost DocumentRoot "/Library/Webserver/Documents_AMNIOT" </VirtualHost>... Code OSX Virtual Web Host Config Macintosh
-
<?php define('DRUPAL_ROOT', getcwd()); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); require_once DRUPAL_ROOT . '/includes/password.inc'; if (isset($_GET['pass']) && !empty($_GET['pass'])) { $newhash = user_hash_password($_GET['pass']); } else { die('Retry with ?pass=PASSWORD set in the URL'); } $updatepass = db_update('users') ->fields(array( 'pass' => $newhash, // Uncomment the following lines to reset the administrative username and/or email address, if necessary. // 'name' => 'admin', // 'mail' => 'yourmail@example.com' )) ->condition('uid', '1', '=') ->execute(); print "Done. Please delete this file immediately!"; drupal_exit(); ?>... Code Manually reset Drupal admin password Drupal
-
<?php function get_species_country($id_country) { $inner = new EntityFieldQuery(); $inner_r = $inner->entityCondition('entity_type', 'field_collection_item') ->fieldCondition('field_species_country', 'target_id', $id_country, '=') ->execute(); if(!empty($inner_r['field_collection_item'])) { $keys = array_keys($inner_r['field_collection_item']); $query = new EntityFieldQuery(); $species_r = $query->entityCondition('entity_type', 'node') ->entityCondition('bundle', self::$bundle) ->fieldCondition('field_species_countries', 'value', $keys) ->execute(); if(!empty($species_r['node'])) { $ret = node_load_multiple(array_keys($species_r['node'])); } } return $ret; } ?>... Code Nested-query approach to mining field_collection data and relationship Template Coding Drupal