Edit

Error message

  • Notice: Undefined variable: monthCounts in include() (line 12 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Notice: Trying to access array offset on value of type null in include() (line 12 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Notice: Undefined variable: monthCounts in include() (line 14 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Warning: array_reverse() expects parameter 1 to be array, null given in include() (line 14 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Warning: Invalid argument supplied for foreach() in include() (line 21 of /homepages/21/d93015512/htdocs/library/organic_connectivity/date_overview.tpl.php).
  • Notice: Undefined offset: 0 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 1 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 2 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 3 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 4 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 5 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 6 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 7 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 8 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 9 in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 42 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 0 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 1 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 2 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 3 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 4 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 5 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 6 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 7 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 8 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).
  • Notice: Undefined offset: 9 in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Notice: Trying to get property 'connections' of non-object in include() (line 150 of /homepages/21/d93015512/htdocs/library/organic_connectivity/items_map.tpl.php).
  • Warning: Invalid argument supplied for foreach() in search_for_attribute() (line 641 of /homepages/21/d93015512/htdocs/library/organic_connectivity/io.php).

Items

Items

112

Per Page

/ 12

Subject Attribute

Nodes Posts Things

Blocks

items_blocks.tpl.php

Nodes

items_nodes.tpl.php

  • Various WP snippets

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics

    Show Links Menu w/Active Class

    <nav>
    <?php $args=array(
    	'sort_order' => 'ASC',
    	'sort_column' => 'post_date',
    	'hierarchical' => 1,
    	'exclude' => '',
    	'include' => '',
    	'meta_key' => '',
    	'meta_value' => '',
    	'authors' => '',
    	'child_of' => 0,
    	'parent' => -1,
    	'exclude_tree' => '',
    	'number' => '',
    	'offset' => 0,
    	'post_type' => 'page',
    	'post_status' => 'publish'
    );
    $pages = get_pages($args);
    $current_id = get_the_ID();
    if( $pages ){
        echo( "<ul>\n" );
        foreach( $pages as $page){
            $link_page_id = ($page->ID);
            if( $current_id==$link_page_id ) echo( "<li class=\"active\">" );
            else echo( "<li>" );
            echo( "<a href=\"".get_page_link($page->ID)."\">".$page->post_title."</a>" );
            echo( "</li>\n" );
        }
        echo( "</ul>\n\n" );
    }
    ?>
    </nav>

    Show Categories List

    <?php
        echo( "<div id=\"topics\">\n" );
        echo( "<h3>Topics</h3>\n" );
        echo( "<ul>\n" );
        $categories_obj = get_categories( array('orderby'=>'id','hide_empty'=>'1') );
        foreach( $categories_obj as $cat ){
            echo( "<li>" );
            echo( "<a href=\"/category/".$cat->slug."\">".$cat->name."</a>" );
            $posts_in_cat = new WP_Query( 'cat='.$cat->term_id );
            if ( $posts_in_cat->have_posts() ){
                echo( "<ul>\n" );
                while ( $posts_in_cat->have_posts() ){
                    $posts_in_cat->the_post();
                    echo( "<li><a href=\"");
                    the_permalink();
                    echo( "\">" );
                    the_title();
                    echo( "</a></li>\n" );
                }
                echo( "</ul>\n" );
            }
            echo( "</li>\n" );
        }
        echo( "</ul>\n" );
        echo( "</div>\n\n" );
    ?>

    Show Recent Posts List

    <?php
        echo( "<h2>What's New</h2>\n" );
        echo( "<ul>\n" );
        $latest_blog_posts = new WP_Query( array('posts_per_page'=>5) );
        if ( $latest_blog_posts->have_posts() ) :
            while ( $latest_blog_posts->have_posts() ) :
                $latest_blog_posts->the_post();
                // Loop output goes here
                echo( "<li><a href=\"");
                the_permalink();
                echo( "\">" );
                the_title();
                echo( "</a></li>\n" );
            endwhile;
        endif;
        echo( "</ul>\n" );
    }
    ?>

    Show Recent Posts Content

    <?php
        echo( "<?h2>Recent Posts<?/h2>\n" );
        $latest_blog_posts = new WP_Query( array( 'posts_per_page'=>5 ) );
        if ( $latest_blog_posts->have_posts() ){
            while ( $latest_blog_posts->have_posts() ){
                $latest_blog_posts->the_post();
                // Loop output goes here
                echo( "<?div class=\"entry\">\n" );
                echo( "<?h3>" );
                echo( "<?a href=\"" );
                the_permalink();
                echo( "\">" );
                the_title();
                echo( "<?/a>" );
                echo( "<?/h3>\n" );
                echo( "<?div class=\"time\">\n" );
                the_date();
                echo( "@" );
                the_time();
                echo( "<?/div>\n" );
                echo( "<?h4>in Categories<?/h4>" );
                the_category();
                the_content();
                echo( "<?/div>\n\n" );
            }
        }
    ?>

    Show Date Menu

    <?php
        echo("<h2>Archive</h2>\n");
        echo("<ul>\n");
        wp_get_archives();
        echo("</ul>\n");
    ?>

    Show Tag List

    <?php
        echo("<div id=\"tag-bar\">\n");
        echo("<ul>\n");
        $tags_obj = get_tags(array('orderby'=>'name','order'=>'ASC','hide_empty'=>'1'));
        foreach($tags_obj as $tag){
            echo("<li>");
            echo("<a href=\"/tag/".$tag->slug."\">".$tag->name."</a>");
            echo(" (".$tag->count.")");
            echo("</li>\n");
        }
        echo("</ul>\n");
        echo("</div>\n\n");
    ?>

    Add ability to execute php in text widgets

    <?php
    add_filter('widget_text','php_text',99);
    function php_text($text){
        if(strpos($text,'<'.'?')!==false){
            ob_start();
            eval('?'.'>'.$text);
            $text=ob_get_contents();
            ob_end_clean();
        }
        return $text;
    }
    ?>

    Removes the automatic addition of P and BR elements to content

    <?php
    remove_filter('the_content','wpautop');
    remove_filter('the_excerpt','wpautop');
    remove_filter('term_description','wpautop');
    ?>

    Using email as username in account registration

    <?php
    if(isset($_POST['user_login'])&&isset($_POST['user_email'])){
        $_POST['user_login']=$_POST['user_email'];
    }
    ?>

    Storing user-selected password into database on registration

    <?php
    add_action('user_register','ts_register_extra_fields',100);
    function ts_register_extra_fields($user_id){
        $userdata=array();
        $userdata['ID']=$user_id;
        if($_POST['user_password']!==''){
            $userdata['user_pass']=$_POST['user_password'];
        }
        $new_user_id=wp_update_user($userdata);
    }
    ?>

    Add ability to add featured images to pages and posts

    <?php
    add_theme_support('post-thumbnails');
    ?>

    Add ability to execute shortcodes in text widgets

    <?php
    add_filter('widget_text','do_shortcode');
    ?>

    Define menus

    <?php
    if(function_exists('register_nav_menus')){
        register_nav_menus(
            array(
                'main_menu'=>'Main Menu',
                'footer_menu'=>'Footer Menu',
            )
        );
    }
    ?>

    Define widget regions

    <?php
    if(function_exists('register_sidebar')){
        register_sidebar(array(
            'name'=>'Footer',
            'id'=>'footer',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
        register_sidebar(array(
            'name'=>'Footer Right',
            'id'=>'footer_right',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
        register_sidebar(array(
            'name'=>'Sidebar Right',
            'id'=>'sidebar_right',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
    }
    ?>
  • Output a menu

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    
    $page_menu_items = menu_tree_output(menu_tree_all_data("main-menu"));
    
    echo( drupal_render($page_menu_items) );
    
    
    ?>
  • LDAP Connect and Bind Test

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    
    $host = "127.0.0.1:10389";
    $ldap = ldap_connect($host);
    ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
    
    
    $username = "uid=admin,ou=system";
    $password = "secret";
    
    
    if( $bind = ldap_bind($ldap, $username, $password) )
    
        echo( "logged into ".$host." as ".$username );
    
    else
    
        echo( "Fail" );
    
    
    ?>
  • Create custom content type

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics

    contenttypetest.info

    name = Contenttype test
    description = Test - how can I create a new content type with hook form?
    core = 7.x
    files[] = contenttypetest.module;
    files[] = contenttypetest.install;

    contenttypetest.module

    <?php
    
        // hook_form implementation
        function contenttypetest_form($node, &$form_state) {
            $form = array();
    
    
            $form['contenttypetest_pass'] = array(
                '#type' => 'password',
                '#title' => t('Type a password'),
                '#description' => t('You can type anything you like.'),
            );
            $form['contenttypetest_veld'] = array(
                '#type' => 'file',
                '#description' => 'You might wanna upload a file!',
                '#title' => 'Bestand',
            );
            return $form;
        }
    
    
        // hook_node_info() implementation
        function contenttypetest_node_info() {
            return array(
                'contenttypetest' => array(
                    'name' => t('Content type test node'),
                    'base' => 'contenttypetest',
                    'module' => 'contenttypetest',
                    'description' => t("This nodetype is a test how to create nodetypes."),
                    'help' => 'So this is how your new contenttype looks!',
                    'title_label' => t('Test'),
                    'has_body' => FALSE,
                ),
            );
        }
    
    
        // hook_validate() implementation
        function contenttypetest_validate(){
        }
    
    ?>

    contenttypetest.install

    <?php
    
        // hook_uninstall() implementation
        function contenttypetest_uninstall(){
            node_type_delete('contenttypetest');
        }
    
    ?>
  • Fill array with server request URI strings

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    
    $request = explode( "/", $_SERVER["REQUEST_URI"] );
    array_shift( $request );
    
    print_r( $requests );
    
    ?>
  • Render imagecache images

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    echo( "<img src=\"".image_style_url("thumbnail", $photo["uri"] )."\" alt=\"\"/>" );
  • Add unique IDs to menu items

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    function HOOK_menu_link( array $variables ){
    
        $element = $variables['element'];
        $sub_menu = '';
        $name_id = strtolower(strip_tags($element['#title']));
    
        // remove colons and anything past colons
        if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':'));
    
        //Preserve alphanumerics, everything else goes away
        $pattern = '/[^a-z]+/ ';
        $name_id = preg_replace($pattern, '', $name_id);
    
        $element['#attributes']['id'][] = 'menu-' . $element['#original_link']['mlid'] . ' '.$name_id;
    
        if( $element['#below'] )
            $sub_menu = drupal_render($element['#below']);
    
        $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    
        return '' . $output . $sub_menu . "
  • \n"; } ?>
  • Obtain matching entities

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    function obtain_entities_by_type($entity_type,$bundle,$limit=10,$offset=0,$subject_nid=FALSE){
    
        $query=new EntityFieldQuery();
    
        $query->entityCondition('entity_type', $entity_type)
            ->entityCondition('bundle', $bundle)
            ->propertyCondition('status', 1)
            ->range($offset, $limit);
    
        if($subject_nid)
            $query->fieldCondition('field_subject','nid',$subject_nid);
    
        $results=$query->execute();
    
        if(array_key_exists('node',$results))
            return entity_load($entity_type,array_keys($results[$entity_type]));
    
    }

    Useage

    obtain_entities_by_type('node','page',10,0,432);

    Or

    <?php
    $sql="SELECT node.nid AS nid,
    node.title AS node_title,
    node.created AS node_created,
    node_data_field_weight.field_weight_value AS node_data_field_weight_field_weight_value
     FROM node node
     LEFT JOIN content_field_weight node_data_field_weight ON node.vid = node_data_field_weight.vid
     WHERE (node.status <> 0)
        ORDER BY node_data_field_weight_field_weight_value DESC";
    
    $db_query=db_query($sql);
    
    $items=array();
    while($row=db_fetch_array($db_query))
    	$items[]=array( $row["node_title"], $row["node_created"], $row["nid"], $row["node_data_field_weight_field_weight_value"] );
    
    echo("<pre>".print_r($items,TRUE)."</pre>\n\n");
    
    ?>

    Or

    <?php
    function snag_drupal_pages(){
        $sql_children="SELECT node.nid AS nid, node.vid AS node_vid, node.title AS node_title
         FROM node node
         WHERE node.type in ('page')";
        $db_query_children = db_query($sql_children);
        $pages=array();
        foreach($db_query_children as $row){
        	$nd=node_load($row->nid);
        	$key=array_push( $pages,array() ) - 1;
        	$pages[$key]["id"] = $row->nid;
        	$pages[$key]["title"] = $nd->title;
        	$pages[$key]["date"] = $nd->created;
        	if( drupal_lookup_path('alias',"node/".$nd->nid) ) $pages[$key]["path"] = drupal_lookup_path('alias',"node/".$nd->nid);
        	else $pages[$key]["path"] = "node/".$nd->nid;
        	if( !empty($nd->field_parent_page) ) $pages[$key]["group"] = $nd->field_parent_page["und"][0]["nid"];
        }
        #echo("<pre>");print_r($pages);echo("</pre>\n");
        return $pages;
    }
    ?>
  • Show field when a different selection is made on the same form

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    function HOOK_form_alter( &$form, &$form_state, $form_id ){
    
        if( $form_id == "user_register_form" || $form_id == "user_profile_form" ) {
    
    
            // Shows OTHER text field when 'Other' is selected as their specialty
    
            $form["field_specialty_other"]["#states"] = array(
                "visible" => array(
                    ':input[name="field_specialty[und]"]' => array("value"=>"Other"),
                )
            );
    
    
        }
    
    }
  • Insert email as username at registration

    Context: 
    Connection: 
    Attribute Type: 
    Types
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    Connection: 
    Weight: 
    100
    Attribute Type: 
    Topics
    <?php
    function HOOK_user_insert( &$edit, &$account, $category = NULL ){
    
        // Don't create a new username if one is already set
        if( strpos($account->name, 'temporary_') !== 0)
            return;
    
        // Otherwise, replace username with email address field
        db_update("users")
            ->fields(array("name" => $edit["mail"]))
            ->condition("uid", $account->uid)
            ->execute();
    
        $edit["name"] = $edit["mail"];
        $account->name = $edit["mail"];
        return;
    }
    
    
    function HOOK_user_register_form_alter( &$form, &$form_state, $form_id ){
    
        $form["account"]["name"]["#value"] = "temporary_".user_password();
        $form["account"]["name"]["#access"] = FALSE;
    
    }?>
  • Table

    items_table.tpl.php

    ID Images/Body Types Title Subjects Attributes Edit
    101 Show Links Menu w/Active Class <nav> <?php $args=array( 'sort_order' => 'ASC', 'sort_column' => 'post_date', 'hierarchical' => 1, 'exclude' => '', 'include' => '', 'meta_key' => '', 'meta_value' => '', 'authors' => '', 'child_of' => 0, 'parent' => -1, 'exclude_tree' => '', 'number' => '', 'offset' => 0, 'post_type' => 'page', 'post_status' => 'publish' ); $pages = get_pages($args); $current_id = get_the_ID(); if( $pages ){ echo( "<ul>\n" ); fore Various WP snippets
    EDIT
    100 <?php $page_menu_items = menu_tree_output(menu_tree_all_data("main-menu")); echo( drupal_render($page_menu_items) ); ?> Output a menu
    EDIT
    99 <?php $host = "127.0.0.1:10389"; $ldap = ldap_connect($host); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); $username = "uid=admin,ou=system"; $password = "secret"; if( $bind = ldap_bind($ldap, $username, $password) ) echo( "logged into ".$host." as ".$username ); else echo( "Fail" ); ?> LDAP Connect and Bind Test
    EDIT
    98 contenttypetest.info name = Contenttype test description = Test - how can I create a new content type with hook form? core = 7.x files[] = contenttypetest.module; files[] = contenttypetest.install; contenttypetest.module <?php // hook_form implementation function contenttypetest_form($node, &$form_state) { $form = array(); $form['contenttypetest_pass'] = array( '#type' => 'password', '#title' => t('Type a password'), '#description' => t('You can type Create custom content type
    EDIT
    97 <?php $request = explode( "/", $_SERVER["REQUEST_URI"] ); array_shift( $request ); print_r( $requests ); ?> Fill array with server request URI strings
    EDIT
    96 echo( "<img src=\"".image_style_url("thumbnail", $photo["uri"] )."\" alt=\"\"/>" ); Render imagecache images
    EDIT
    95 <?php function HOOK_menu_link( array $variables ){ $element = $variables['element']; $sub_menu = ''; $name_id = strtolower(strip_tags($element['#title'])); // remove colons and anything past colons if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':')); //Preserve alphanumerics, everything else goes away $pattern = '/[^a-z]+/ '; $name_id = preg_replace($pattern, '', $name_id); $element['#attributes']['id'][] = 'menu-' . $element['#original_link']['mlid'] . ' '.$name_ Add unique IDs to menu items
    EDIT
    94 function obtain_entities_by_type($entity_type,$bundle,$limit=10,$offset=0,$subject_nid=FALSE){ $query=new EntityFieldQuery(); $query->entityCondition('entity_type', $entity_type) ->entityCondition('bundle', $bundle) ->propertyCondition('status', 1) ->range($offset, $limit); if($subject_nid) $query->fieldCondition('field_subject','nid',$subject_nid); $results=$query->execute(); if(array_key_exists('node',$results)) return entity_load($entity_type,array_k Obtain matching entities
    EDIT
    93 function HOOK_form_alter( &$form, &$form_state, $form_id ){ if( $form_id == "user_register_form" || $form_id == "user_profile_form" ) { // Shows OTHER text field when 'Other' is selected as their specialty $form["field_specialty_other"]["#states"] = array( "visible" => array( ':input[name="field_specialty[und]"]' => array("value"=>"Other"), ) ); } } Show field when a different selection is made on the same form
    EDIT
    92 <?php function HOOK_user_insert( &$edit, &$account, $category = NULL ){ // Don't create a new username if one is already set if( strpos($account->name, 'temporary_') !== 0) return; // Otherwise, replace username with email address field db_update("users") ->fields(array("name" => $edit["mail"])) ->condition("uid", $account->uid) ->execute(); $edit["name"] = $edit["mail"]; $account->name = $edit["mail"]; return; } function HOOK_user_register_form_alter( &am Insert email as username at registration
    EDIT

    Rotator

    items_cinema.tpl.php

    Calendar

    date_overview.tpl.php

    Start date

    Total Items

    RSS

    items_syndicate.tpl.php

    
    
    
        
    
            Organic Interfaces
    
            http://interfaces.orgnsm.org/syndicate
    
            Recent Web Design & Info Code
    
            en
    
            Tue, 17 Dec 2013 20:02:27 -1000
    
            
    
    
     Various WP snippets
     http://interfaces.orgnsm.org/node/101
     Show Links Menu w/Active Class
    
    <nav>
    <?php $args=array(
    	'sort_order' => 'ASC',
    	'sort_column' => 'post_date',
    	'hierarchical' => 1,
    	'exclude' => '',
    	'include' => '',
    	'meta_key' => '',
    	'meta_value' => '',
    	'authors' => '',
    	'child_of' => 0,
    	'parent' => -1,
    	'exclude_tree' => '',
    	'number' => '',
    	'offset' => 0,
    	'post_type' => 'page',
    	'post_status' => 'publish'
    );
    $pages = get_pages($args);
    $current_id = get_the_ID();
    if( $pages ){
        echo( "<ul>\n" );
        foreach( $pages as $page){
            $link_page_id = ($page->ID);
            if( $current_id==$link_page_id ) echo( "<li class=\"active\">" );
            else echo( "<li>" );
            echo( "<a href=\"".get_page_link($page->ID)."\">".$page->post_title."</a>" );
            echo( "</li>\n" );
        }
        echo( "</ul>\n\n" );
    }
    ?>
    </nav>

    Show Categories List

    <?php
        echo( "<div id=\"topics\">\n" );
        echo( "<h3>Topics</h3>\n" );
        echo( "<ul>\n" );
        $categories_obj = get_categories( array('orderby'=>'id','hide_empty'=>'1') );
        foreach( $categories_obj as $cat ){
            echo( "<li>" );
            echo( "<a href=\"/category/".$cat->slug."\">".$cat->name."</a>" );
            $posts_in_cat = new WP_Query( 'cat='.$cat->term_id );
            if ( $posts_in_cat->have_posts() ){
                echo( "<ul>\n" );
                while ( $posts_in_cat->have_posts() ){
                    $posts_in_cat->the_post();
                    echo( "<li><a href=\"");
                    the_permalink();
                    echo( "\">" );
                    the_title();
                    echo( "</a></li>\n" );
                }
                echo( "</ul>\n" );
            }
            echo( "</li>\n" );
        }
        echo( "</ul>\n" );
        echo( "</div>\n\n" );
    ?>

    Show Recent Posts List

    <?php
        echo( "<h2>What's New</h2>\n" );
        echo( "<ul>\n" );
        $latest_blog_posts = new WP_Query( array('posts_per_page'=>5) );
        if ( $latest_blog_posts->have_posts() ) :
            while ( $latest_blog_posts->have_posts() ) :
                $latest_blog_posts->the_post();
                // Loop output goes here
                echo( "<li><a href=\"");
                the_permalink();
                echo( "\">" );
                the_title();
                echo( "</a></li>\n" );
            endwhile;
        endif;
        echo( "</ul>\n" );
    }
    ?>

    Show Recent Posts Content

    <?php
        echo( "<?h2>Recent Posts<?/h2>\n" );
        $latest_blog_posts = new WP_Query( array( 'posts_per_page'=>5 ) );
        if ( $latest_blog_posts->have_posts() ){
            while ( $latest_blog_posts->have_posts() ){
                $latest_blog_posts->the_post();
                // Loop output goes here
                echo( "<?div class=\"entry\">\n" );
                echo( "<?h3>" );
                echo( "<?a href=\"" );
                the_permalink();
                echo( "\">" );
                the_title();
                echo( "<?/a>" );
                echo( "<?/h3>\n" );
                echo( "<?div class=\"time\">\n" );
                the_date();
                echo( "@" );
                the_time();
                echo( "<?/div>\n" );
                echo( "<?h4>in Categories<?/h4>" );
                the_category();
                the_content();
                echo( "<?/div>\n\n" );
            }
        }
    ?>

    Show Date Menu

    <?php
        echo("<h2>Archive</h2>\n");
        echo("<ul>\n");
        wp_get_archives();
        echo("</ul>\n");
    ?>

    Show Tag List

    <?php
        echo("<div id=\"tag-bar\">\n");
        echo("<ul>\n");
        $tags_obj = get_tags(array('orderby'=>'name','order'=>'ASC','hide_empty'=>'1'));
        foreach($tags_obj as $tag){
            echo("<li>");
            echo("<a href=\"/tag/".$tag->slug."\">".$tag->name."</a>");
            echo(" (".$tag->count.")");
            echo("</li>\n");
        }
        echo("</ul>\n");
        echo("</div>\n\n");
    ?>

    Add ability to execute php in text widgets

    <?php
    add_filter('widget_text','php_text',99);
    function php_text($text){
        if(strpos($text,'<'.'?')!==false){
            ob_start();
            eval('?'.'>'.$text);
            $text=ob_get_contents();
            ob_end_clean();
        }
        return $text;
    }
    ?>

    Removes the automatic addition of P and BR elements to content

    <?php
    remove_filter('the_content','wpautop');
    remove_filter('the_excerpt','wpautop');
    remove_filter('term_description','wpautop');
    ?>

    Using email as username in account registration

    <?php
    if(isset($_POST['user_login'])&&isset($_POST['user_email'])){
        $_POST['user_login']=$_POST['user_email'];
    }
    ?>

    Storing user-selected password into database on registration

    <?php
    add_action('user_register','ts_register_extra_fields',100);
    function ts_register_extra_fields($user_id){
        $userdata=array();
        $userdata['ID']=$user_id;
        if($_POST['user_password']!==''){
            $userdata['user_pass']=$_POST['user_password'];
        }
        $new_user_id=wp_update_user($userdata);
    }
    ?>

    Add ability to add featured images to pages and posts

    <?php
    add_theme_support('post-thumbnails');
    ?>

    Add ability to execute shortcodes in text widgets

    <?php
    add_filter('widget_text','do_shortcode');
    ?>

    Define menus

    <?php
    if(function_exists('register_nav_menus')){
        register_nav_menus(
            array(
                'main_menu'=>'Main Menu',
                'footer_menu'=>'Footer Menu',
            )
        );
    }
    ?>

    Define widget regions

    <?php
    if(function_exists('register_sidebar')){
        register_sidebar(array(
            'name'=>'Footer',
            'id'=>'footer',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
        register_sidebar(array(
            'name'=>'Footer Right',
            'id'=>'footer_right',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
        register_sidebar(array(
            'name'=>'Sidebar Right',
            'id'=>'sidebar_right',
            'before_widget'=>'<div>',
            'after_widget'=>'</div>',
            'before_title'=>'<h2>',
            'after_title'=>'</h2>',
        ));
    }
    ?>
    ]]>
    101 Tue, 17 Dec 2013 20:02:27 -1000
    Output a menu http://interfaces.orgnsm.org/node/100 <?php $page_menu_items = menu_tree_output(menu_tree_all_data("main-menu")); echo( drupal_render($page_menu_items) ); ?>
    ]]> 100 Tue, 17 Dec 2013 17:33:26 -1000 LDAP Connect and Bind Test http://interfaces.orgnsm.org/node/99 <?php $host = "127.0.0.1:10389"; $ldap = ldap_connect($host); ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); $username = "uid=admin,ou=system"; $password = "secret"; if( $bind = ldap_bind($ldap, $username, $password) ) echo( "logged into ".$host." as ".$username ); else echo( "Fail" ); ?> ]]> 99 Fri, 13 Dec 2013 20:41:40 -1000 Create custom content type http://interfaces.orgnsm.org/node/98 contenttypetest.info
    name = Contenttype test
    description = Test - how can I create a new content type with hook form?
    core = 7.x
    files[] = contenttypetest.module;
    files[] = contenttypetest.install;

    contenttypetest.module

    <?php
    
        // hook_form implementation
        function contenttypetest_form($node, &$form_state) {
            $form = array();
    
    
            $form['contenttypetest_pass'] = array(
                '#type' => 'password',
                '#title' => t('Type a password'),
                '#description' => t('You can type anything you like.'),
            );
            $form['contenttypetest_veld'] = array(
                '#type' => 'file',
                '#description' => 'You might wanna upload a file!',
                '#title' => 'Bestand',
            );
            return $form;
        }
    
    
        // hook_node_info() implementation
        function contenttypetest_node_info() {
            return array(
                'contenttypetest' => array(
                    'name' => t('Content type test node'),
                    'base' => 'contenttypetest',
                    'module' => 'contenttypetest',
                    'description' => t("This nodetype is a test how to create nodetypes."),
                    'help' => 'So this is how your new contenttype looks!',
                    'title_label' => t('Test'),
                    'has_body' => FALSE,
                ),
            );
        }
    
    
        // hook_validate() implementation
        function contenttypetest_validate(){
        }
    
    ?>

    contenttypetest.install

    <?php
    
        // hook_uninstall() implementation
        function contenttypetest_uninstall(){
            node_type_delete('contenttypetest');
        }
    
    ?>
    ]]>
    98 Wed, 11 Dec 2013 12:42:24 -1000
    Fill array with server request URI strings http://interfaces.orgnsm.org/node/97 <?php $request = explode( "/", $_SERVER["REQUEST_URI"] ); array_shift( $request ); print_r( $requests ); ?> ]]> 97 Mon, 09 Dec 2013 17:20:59 -1000 Render imagecache images http://interfaces.orgnsm.org/node/96 echo( "<img src=\"".image_style_url("thumbnail", $photo["uri"] )."\" alt=\"\"/>" ); ]]> 96 Sun, 08 Dec 2013 19:21:51 -1000 Add unique IDs to menu items http://interfaces.orgnsm.org/node/95 <?php function HOOK_menu_link( array $variables ){ $element = $variables['element']; $sub_menu = ''; $name_id = strtolower(strip_tags($element['#title'])); // remove colons and anything past colons if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':')); //Preserve alphanumerics, everything else goes away $pattern = '/[^a-z]+/ '; $name_id = preg_replace($pattern, '', $name_id); $element['#attributes']['id'][] = 'menu-' . $element['#original_link']['mlid'] . ' '.$name_id; if( $element['#below'] ) $sub_menu = drupal_render($element['#below']); $output = l($element['#title'], $element['#href'], $element['#localized_options']); return '' . $output . $sub_menu . "\n"; } ?> ]]> 95 Fri, 06 Dec 2013 14:58:18 -1000 Obtain matching entities http://interfaces.orgnsm.org/node/94 function obtain_entities_by_type($entity_type,$bundle,$limit=10,$offset=0,$subject_nid=FALSE){ $query=new EntityFieldQuery(); $query->entityCondition('entity_type', $entity_type) ->entityCondition('bundle', $bundle) ->propertyCondition('status', 1) ->range($offset, $limit); if($subject_nid) $query->fieldCondition('field_subject','nid',$subject_nid); $results=$query->execute(); if(array_key_exists('node',$results)) return entity_load($entity_type,array_keys($results[$entity_type])); }

    Useage

    obtain_entities_by_type('node','page',10,0,432);

    Or

    <?php
    $sql="SELECT node.nid AS nid,
    node.title AS node_title,
    node.created AS node_created,
    node_data_field_weight.field_weight_value AS node_data_field_weight_field_weight_value
     FROM node node
     LEFT JOIN content_field_weight node_data_field_weight ON node.vid = node_data_field_weight.vid
     WHERE (node.status <> 0)
        ORDER BY node_data_field_weight_field_weight_value DESC";
    
    $db_query=db_query($sql);
    
    $items=array();
    while($row=db_fetch_array($db_query))
    	$items[]=array( $row["node_title"], $row["node_created"], $row["nid"], $row["node_data_field_weight_field_weight_value"] );
    
    echo("<pre>".print_r($items,TRUE)."</pre>\n\n");
    
    ?>

    Or

    <?php
    function snag_drupal_pages(){
        $sql_children="SELECT node.nid AS nid, node.vid AS node_vid, node.title AS node_title
         FROM node node
         WHERE node.type in ('page')";
        $db_query_children = db_query($sql_children);
        $pages=array();
        foreach($db_query_children as $row){
        	$nd=node_load($row->nid);
        	$key=array_push( $pages,array() ) - 1;
        	$pages[$key]["id"] = $row->nid;
        	$pages[$key]["title"] = $nd->title;
        	$pages[$key]["date"] = $nd->created;
        	if( drupal_lookup_path('alias',"node/".$nd->nid) ) $pages[$key]["path"] = drupal_lookup_path('alias',"node/".$nd->nid);
        	else $pages[$key]["path"] = "node/".$nd->nid;
        	if( !empty($nd->field_parent_page) ) $pages[$key]["group"] = $nd->field_parent_page["und"][0]["nid"];
        }
        #echo("<pre>");print_r($pages);echo("</pre>\n");
        return $pages;
    }
    ?>
    ]]>
    94 Thu, 05 Dec 2013 18:13:58 -1000
    Show field when a different selection is made on the same form http://interfaces.orgnsm.org/node/93 function HOOK_form_alter( &$form, &$form_state, $form_id ){ if( $form_id == "user_register_form" || $form_id == "user_profile_form" ) { // Shows OTHER text field when 'Other' is selected as their specialty $form["field_specialty_other"]["#states"] = array( "visible" => array( ':input[name="field_specialty[und]"]' => array("value"=>"Other"), ) ); } } ]]> 93 Tue, 03 Dec 2013 16:09:46 -1000 Insert email as username at registration http://interfaces.orgnsm.org/node/92 <?php function HOOK_user_insert( &$edit, &$account, $category = NULL ){ // Don't create a new username if one is already set if( strpos($account->name, 'temporary_') !== 0) return; // Otherwise, replace username with email address field db_update("users") ->fields(array("name" => $edit["mail"])) ->condition("uid", $account->uid) ->execute(); $edit["name"] = $edit["mail"]; $account->name = $edit["mail"]; return; } function HOOK_user_register_form_alter( &$form, &$form_state, $form_id ){ $form["account"]["name"]["#value"] = "temporary_".user_password(); $form["account"]["name"]["#access"] = FALSE; }?> ]]> 92 Mon, 25 Nov 2013 14:44:09 -1000

    Global

    items_map.tpl.php