Tuesday, 23 February 2016

Drupal 7 Folder Structure

Basic Directory Structure of a Drupal 7 Project

By following the standard for the directory structure of a Drupal 7 project, you can keep

your project able to update, stay secure, extensible and understandable for others and

yourself - especially when you get again into the project after a certain time. Additionally the

standard is something which saves you from creating a hardly maintainable legacy code-

base, that is no fun to work with.

Core parts of your project

Do not touch the following folders. Except for Drupal core updates or contribution to the Drupal

core. If you think that there's a bug in the Drupal core, don't edit the code first -check the

issue queue first.

 /includes: Helper functions (e.g. image manipulation, password generation etc.)

 /misc: JavaScripts, icon-images for messages etc.

 /modules: the modules from the Drupal core.

 /profiles: the installation profiles from the Drupal core (minimal, standard, testing). Drupal will ask you

which profile you want to install when first installing your Drupal site.

 /scripts: contains various scripts. e.g. to execute the cron, dump the database, generate a password

hash and run the tests.

 /themes: here are the Drupal core themes located. Such as the default Bartik themeand the Seven

theme which is the default one for administration pages.

 /sites: Here comes anything which is not part of the Drupal core. Contains an "all"- and a "default"-folder.

In the "all"-folder you can place your custom and contrib modules and themes. Additionally here's a

"default"-folder where your site configuration resides. After a Drupal site is installed, there will be a

settings.php file in the "default"-folder, where usually the database configuration and other site-specific

configurations are. You're free to place other configuration files in the default folder. The reason for the

naming "all" and "default" is the Drupal multi-site setup.

 [Optional] /sites/my-website-a.com and /sites/my-website-b.com etc.: Drupal is able for multi-site

configuration. If you point your webserver into the Drupal root directory, Drupal can manage to handle

separate modules, themes and configuration by sharing one Drupal core and specific modules or themes

between an number of Drupal websites. You can even share specific database tables (such as the user

table) or 1 database between multple Drupal sites.

 /sites/all: Any modules and themes in this folder will be available to all instances managed by this code

base. So if you are running multisite, the modules and themes will be available to each of the multi sites.

If you have only 1 website instance managed by Drupal, you can place them in this folder.

 /sites/all/modules: Here you can put all your contrib and custom modules. Please notice: don't edit

contrib modules directly on bugs or any other issues. Firstly take a look into the issue queue for the

specific project, create patch or fork the project/module/theme. If you decide to fork a module or theme,

consider to release your fork on Drupal.org by a full project application.

 /sites/all/themes: That place is ment to hold your custom or contrib themes. You cancreate your own

themes or a sub-theme like for the Zen theme. Please notice to keep any PHP logic as most as possible

separate from the theme. Database queries, PHP classes and similiar are better located in a Drupal

module.

 [Optional] /sites/all/modules/custom: Often Drupal users place here their custom modules. The modules

which are not released officially on Drupal.org. Be careful with this folder. Sometimes other projects don't

recognize this sub-folder. But mostly they do (like Drush and the Drupal module management system).

You're most safe, if you even place your custom modules in the /sites/all/modules folder. Then you can

prefix your module names, to easier seperate them from the contrib modules. For example:

"my_client_fancy_field".

 [Optional] /sites/all/modules/contrib: Often Drupal users separate in this sub-folder the contrib-modules.

That means modules which are officially released as a full project on Drupal.org. Also be carefully with

this subfolder. Sometimes other projects do not recognize this sub-folder. Your safer with just using the

/sites/all/modules folder. But don't rename the contrib module folders. That would break their functionality.

You can do this with your custom modules.

 [Optional] /sites/all/modules/features: If you manage your Drupal 7 website configuration by the

features module, it could be a good way to seperate the modules, which will be created by the features

module, in this directory. Learn more aboutconfiguration management in Drupal 7. Please notice that in

Drupal 8 the configuration can be managed by the Drupal core.

 /.htaccess: The directory-level configuration file for your project. It contains default configuration such as

for readable URLs. You can edit this file if you have special requirements.

 /.gitignore: In this file you can specify the files and folders which should be ignored by the Git version

control system. Compared with other OpenSource version control systems, Git has one of the most

advantages for development with others via the internet.

 PHP-constant DRUPAL_ROOT: This constant gets the absolute path to your Drupal root directory (such

as /var/www/my-drupal-site).

 conf_path()-function: Gets the path to the Drupal configuration.

 drupal_get_path()-function: Gets the absolute path to a module or theme.

 path_to_theme()-function: It can point to the active theme or the module handling a themed

implementation.

 drupal_realpath('public://'): Gets the path to your public files folder (user uploads etc.).

 file_create_url(): Use this to get a URL for a file - this will ensure that the URL is correct, even when using

language path prefixes.

 image_style_url(): Use this to get the path to a derived image (using Drupal's image styles)

Tuesday, 25 August 2015

Field Collections

Drupal 7- How to get field collection item value for a node


I have a node that has a few field collections on it. When I load the node it gives...
$node = node_load(369);
print_r($node)
Class Object
(
    [vid] => 370
    [uid] => 1187
    [title] => Contacts Approval
    [log] => 
    [status] => 1
    [comment] => 1
    [promote] => 0
    [sticky] => 0
    [nid] => 369
    [type] => contacts_approval
    [language] => und
    [created] => 1395819523
    [changed] => 1395819523
    [tnid] => 0
    [translate] => 0
    [revision_timestamp] => 1395819523
    [revision_uid] => 1187
    [field_contacts] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [value] => 474
                            [revision_id] => 472
                        )

                    [1] => Array
                        (
                            [value] => 475
                            [revision_id] => 473
                        )

                )

        )

    [rdf_mapping] => Array
        (
            [rdftype] => Array
                (
                    [0] => sioc:Item
                    [1] => foaf:Document
                )

            [title] => Array
                (
                    [predicates] => Array
                        (
                            [0] => dc:title
                        )

                )

            [created] => Array
                (
                    [predicates] => Array
                        (
                            [0] => dc:date
                            [1] => dc:created
                        )

                    [datatype] => xsd:dateTime
                    [callback] => date_iso8601
                )

            [changed] => Array
                (
                    [predicates] => Array
                        (
                            [0] => dc:modified
                        )

                    [datatype] => xsd:dateTime
                    [callback] => date_iso8601
                )

            [body] => Array
                (
                    [predicates] => Array
                        (
                            [0] => content:encoded
                        )

                )

            [uid] => Array
                (
                    [predicates] => Array
                        (
                            [0] => sioc:has_creator
                        )

                    [type] => rel
                )

            [name] => Array
                (
                    [predicates] => Array
                        (
                            [0] => foaf:name
                        )

                )

            [comment_count] => Array
                (
                    [predicates] => Array
                        (
                            [0] => sioc:num_replies
                        )

                    [datatype] => xsd:integer
                )

            [last_activity] => Array
                (
                    [predicates] => Array
                        (
                            [0] => sioc:last_activity_date
                        )

                    [datatype] => xsd:dateTime
                    [callback] => date_iso8601
                )

        )

    [cid] => 0
    [last_comment_timestamp] => 1395819523
    [last_comment_name] => 
    [last_comment_uid] => 1187
    [comment_count] => 0
    [name] => yogesh
    [picture] => 0
    [data] => a:1:{s:7:"contact";i:0;}
)



Here we can get the field collections item id or entity id using $node with the help of enitity apis -:

<?php
$node = node_load(369); 
$items = field_get_items('node', $node, 'field_contacts');
//here items are having the entity id/itemid
foreach ($items as $item) {
 $fc = field_collection_field_get_entity($item); // Do something. 
}
?>


Note -:

field_get_items() - : It gives all the related entity id and revision id for the field collection . Here our field collection name is "field_contacts";

field_collection_field_get_entity()-: This entity api helps us to get all the relative information for the entity id in all the related tables.

Monday, 29 June 2015

Hook Examples

hook_form
   modules/node/node.api.php    
Display a node editing form
hook_form_alter        
modules/system/system.api.php
Perform alterations before a form is rendered.

hook_menu   
modules/system/system.api.php   
Define menu items and page callbacks
hook_menu_alter   
modules/system/system.api.php   
Alter the data being saved to the {menu_router} table after hook_menu is invoked
hook_menu_delete    
modules/menu/menu.api.php   
Respond to a custom menu deletion.

hook_node_validate        
modules/node/node.api.php
Perform node validation before a node is created or updated.

module_hook        
includes/module.inc
Determines whether a module implements a hook.

hook_user_categories        
modules/user/user.api.php
Retrieve a list of user setting or profile information categories.

hook_user_delete    
modules/user/user.api.
php     Respond to user deletion.

hook_user_insert    .

modules/user/user.api.php   
A user account was created
hook_user_load        
modules/user/user.api.php
Act on user objects when loaded from the database.

hook_user_login    

modules/user/user.api.php   
The user just logged in.
hook_user_logout    
modules/user/user.api.php   
The user just logged out.

Friday, 26 June 2015

Page--front.tpl.php

<div class="container main-container">
<div class="row">
    <div class="col-lg-4 col-md-6 col-sm-6 col-xs-24">
<?php if ($logo): ?>
 <a  href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
<img class="img-responsive" src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
 </a>
 <?php endif; ?>
</div>
<div class="col-lg-20 col-md-18 col-sm-18 col-xs-24">


<div class="top-btns pull-right">
<ul>
 <li class="sign-in"><a href="#myModal" data-toggle="modal"><i class="fa fa-thumb-tack"></i>Sign In</a></li>
 <div id="myModal" class="modal fade">
<div class="modal-dialog">
 <div class="modal-content position-right">
<div class="online-bank top-scroll">
 <button type="button" class="close pop-up" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
 <h3>Sign In</h3>
 <div class="">
<div class="online-bank-content">
 <input type="text" placeholder="Email Address" name="">
 <input type="password" placeholder="Password" name="">
 <div class="forgot-pass"><a href="https://www.sdfcuib.org/tob/live/usp-core/app/authUpdate#" target="_new">I forgot my password</a></div>
 <input type="submit" class="submit" value="Sign In" name="">
</div>
 </div>
</div>
 </div>
</div>
 </div>
 <?php print render($page['topmenu']); ?>
 <?php /*
          $block = module_invoke('search', 'block_view', 'search');
          print render($block); */
?>
</ul>

</div>


</div>
<div class="col-lg-20 col-md-24 col-sm-24 col-xs-24 alpha omega" >


<div class="menu pull-right omega">
<ul class="visible-xs">
<li class="join"><img src="<?php print $directory; ?>/images/tick-ico.png"><?php print render($page['join']); ?></li>
 <li class="search"><!--<input type="text" placeholder="Search">-->
            <?php print render($page['search']); ?>
          </li>
</ul>

<div class="main-menu">
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
 <div class="navbar-toggle-text">menu</div>
 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" value="MENU"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>

</div>
            <!--/.navbar-header-->
           
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
           
<?php

$main_menu = variable_get('menu_main_links_source', 'menu-sdfcu-menu');
$tree = menu_tree($main_menu);
print render($tree);
//print render($page['mainmenu']);
?>
</div>
            <!--/.navbar-collapse-->
          </nav>
        </div>
        <ul class="hidden-xs">
         
<li class="join"><img src="<?php print $directory; ?>/images/tick-ico.png"><?php print render($page['join']); ?></li>
 <li class="search"><!--<input type="text" placeholder="Search">-->
            <?php print render($page['search']); ?>
          </li>
        </ul>
        <span class="clearfix"></span> </div>
</div>
  </div>
 
 
</div>



<div class="container main-container">
  <div class="row">
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
      <!-- Indicators -->
      <ol class="carousel-indicators banner-controls">
        <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
        <li data-target="#carousel-example-generic" data-slide-to="1"></li>
        <li data-target="#carousel-example-generic" data-slide-to="2"></li>
      </ol>
     
      <!-- Wrapper for slides -->
      <div class="carousel-inner main-banner" role="listbox">
        <!-- Start WOWSlider.com BODY section -->
<div id="wowslider-container1">
<div class="ws_images"><ul>
<li><img src="<?php echo $directory; ?>/data1/images/banner1.png" alt="banner1" title="banner1" id="wows1_0"/></li>
<li><img src="<?php echo $directory; ?>/data1/images/banner2.png" alt="banner2" title="banner2" id="wows1_1"/></li>
<li><img src="<?php echo $directory; ?>/data1/images/banner3.png" alt="banner3" title="banner3" id="wows1_2"/></li>
<li><img src="<?php echo $directory; ?>/data1/images/banner4.png" alt="carousel slider" title="banner4" id="wows1_3"/></li>
<li><img src="<?php echo $directory; ?>/data1/images/banner5.png" alt="banner5" title="banner5" id="wows1_4"/></li>
</ul></div>
<div class="ws_bullets">
<div>
<a href="#" title="banner1"><span><img src="<?php echo $directory; ?>/data1/tooltips/banner1.png" alt="banner1"/>1</span></a>
<a href="#" title="banner2"><span><img src="<?php echo $directory; ?>/data1/tooltips/banner2.png" alt="banner2"/>2</span></a>
<a href="#" title="banner3"><span><img src="<?php echo $directory; ?>/data1/tooltips/banner3.png" alt="banner3"/>3</span></a>
<a href="#" title="banner4"><span><img src="<?php echo $directory; ?>/data1/tooltips/banner4.png" alt="banner4"/>4</span></a>
<a href="#" title="banner5"><span><img src="<?php echo $directory; ?>/data1/tooltips/banner5.png" alt="banner5"/>5</span></a>
</div>
</div>
<div class="ws_shadow"></div>
</div>
<!-- End WOWSlider.com BODY section -->
      </div>
     
   
    </div>
  </div>
</div>
<div class="container main-container">
  <div class="row">
  <h2 class="featured-service-title">Featured Service</h2>
     <div class="col-lg-6 col-md-5 col-sm-24 col-xs-24 online-bank omega">
<form action="https://www.sdfcuib.org/tob/live/usp-core/app/initialLogin" autocomplete="off" id="Login" method="post" name="Login" onsubmit="return setParamStatus();" target="_parent">
<h3>Sign In</h3>
<div class="row">
           
<div class="online-bank-content">
<input placeholder="Email Address" class="style3" id="userNumber" name="userid"   type="text" />
<input  placeholder="Password" id="password" maxlength="25" name="password"   type="password" />
<div class="forgot-pass"><a href="https://www.sdfcuib.org/tob/live/usp-core/app/authUpdate#" target="_new">I forgot my password</a></div>
<input class="submit" type="submit" value="Sign In" />
<input id="testcookie" name="testcookie" type="hidden" value="false" />
<input id="testjs" name="testjs" type="hidden" value="false" />
<input id="dscheck" name="dscheck" type="hidden" value="0" /></td>
</div>
</div>
</form>
    </div>
    <div class="col-lg-18 col-md-24 col-sm-24 col-xs-24">

     
      <ul class="nav nav-tabs tabs-custom" role="tablist" id="myTab">
<?php

$blocks = block_list('featured_services');
foreach($blocks as $block1)
{
?>
<!-- Featured Services Tabs start -->

<li role="presentation">
<a class="<?php echo strtolower(str_replace(' ','_',$block1->title)); ?>" href="#<?php echo strtolower(str_replace(' ','_',$block1->title)); ?>" aria-controls="<?php echo strtolower(str_replace(' ','_',$block1->title)); ?>" role="tab" data-toggle="tab"><?php echo $block1->title; ?></a>
</li>
<?php
}
?>
 </ul>
      <div class="tab-content">
 <?php      
 foreach($blocks as $block1)
 {
 ?>
 <div role="tabpanel" class="tab-pane" id="<?php echo strtolower(str_replace(' ','_',$block1->title)); ?>">
 <?php
echo $block1->content['#markup'];
 ?>
 </div>
 <?php   } ?>
      </div>
      <script>
 jQuery(function () {
jQuery('#myTab a:first').tab('show')
 })
 </script>
    </div>
    </div>
  </div>
</div>
<div class="container main-container">
  <!--<div class="row">-->
  <div class="services">
   
    <?php print render($page['rates']); ?>
  </div>
  <div class="services-tab"><a href="#">View all of SDFU's LOW rates</a> <span class="glyphicon glyphicon-play" aria-hidden="true"></span></div>
 
  <!--</div>-->
</div>
<div class="container main-container">
  <div class="row">
    <div class="col-lg-8 col-md-8 col-sm-8 col-xs-24">
      <div class="help-us">
        <h1 style="border-bottom:none;">Help <b>Us</b>, Help <b>You</b></h1>
        <p><!--We are commited to making your experience with SDFCU The best we can !-->We are commited to you!</p>
        <div class="inner-help-us"> <img src="<?php echo $directory; ?>/images/help-us.png" />
          <p>Take a minute to tell us what we are doing well or what we are doing not so well</p>
        </div>
        <a href="#helpus" data-toggle="modal"><div class="go-img"> </div></a>
        <div id="helpus" class="modal fade">
<div class="modal-dialog">
 <div class="modal-content position-right">
<div class="online-bank top-scroll">
 <button type="button" class="close pop-up" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

 <div class="row">
<div class="membership-comments">
 <?php
module_load_include('inc', 'node', 'node.pages');

$form = node_add('helpus');

print drupal_render($form);
?>
</div>
 </div>
</div>
 </div>
</div>
 </div>
       
      </div>
    </div>
    <div class="col-lg-8 col-md-8 col-sm-8 col-xs-24">
      <div class="help-us">
        <h1 style="border-bottom:none;">Message from our Board</h1>
        <?php print render($page['video']); ?>
</div>
    </div>
    <div class="col-lg-8 col-md-8 col-sm-8 col-xs-24">
<div class="marketing_ads"><ul class="marketing_ads_slider" style="display:none;">
<?php
$nids = db_select('node', 'n')
->fields('n', array('nid','type'))
->condition('n.type', 'marketing_ads')
->execute()
->fetchAll();
foreach($nids as $nid)
{
$node_value= $nid->nid;
$result = node_load($node_value);


?>
<li>

<div class="comming-soon"><a target="_blank" href="<?php echo $result->field_hyperlink['und'][0]['value']; ?>"><img src="<?php echo file_create_url($result->field_marketing_image['und']['0']['uri']); ?>"></a></div>

</li>
<?php
}
?>

       </ul>
       <div class="learn-more"></div>
     
 </div>
    </div>
  </div>
</div>
<div class="container main-container">
  <div class="row">
    <div class="col-lg-8 col-md-8 col-sm-8 col-xs-24">
      <div class="member-test tier1">
        <h1>Member Testimonials</h1>
        <ul class="bxslider" style="display:none">
<?php
print render($page['membertestimonials']);
?>
        </div>
    </div>
    <div class="col-lg-8 col-md-8 col-sm-8 col-xs-24">
      <div class="member-test tier1">
        <h1>Blog Portal</h1>
          <ul class="bxslider" style="display:none;">
<?php
$nids = db_select('node', 'n')
->fields('n', array('nid','type'))
->condition('n.type', 'blog')
->execute()
->fetchAll();
foreach($nids as $nid)
{
$node_value= $nid->nid;
$result = node_load($node_value);
?>
<li>
<h2><a href="<?php print url('node/'.$result->nid); ?>"><?php print $result->title; ?></a></h2>
<div><?php print substr($result->body['und'][0]['value'],0,100); ?> ... <a href="<?php print url('node/'.$result->nid); ?>"> Read more</a> </div>

</li>
<?php
}
?>
</ul>
</div>
    </div>
     <div class="col-lg-8 col-md-8 col-sm-8 col-xs-24">
      <div class="member-test tier1">
  <h1>News and Press</h1>
  <ul class="bxslider" style="display:none">
<?php
$nids = db_select('node', 'n')
->fields('n', array('nid','type'))
->condition('n.type', 'news')
->execute()
->fetchAll();
foreach($nids as $nid)
{
$node_value= $nid->nid;
$result = node_load($node_value);
?>
<li>
<h2><a href="<?php print url('node/'.$result->nid); ?>"><?php print $result->title; ?></a></h2>
<div><?php print substr($result->body['und'][0]['value'],0,100); ?> ... <a href="<?php print url('node/'.$result->nid); ?>"> Read more</a> </div>

</li>
<?php
}
?>
</ul>
 </div>
    </div>


  </div>
</div>


<div class="container-fluid main-container">
  <div class="row">
    <div class="footer">
<div class="container">
<div class="row">
<?php print render($page['footer_links']); ?>
</div>
</div>

<div class="container-fluid footer-top-border">
<div class="container">
<div class="col-lg-24 col-md-24 col-sm-24 col-xs-24 top-footer-menu">
<div class="row">
<?php
$tree = menu_tree_all_data('menu-footer-top-menu');
print drupal_render(menu_tree_output($tree));
?>
</div>
</div>
</div>
</div>

<div class="container">
<?php
$tree2 = menu_tree_all_data('menu-footer-menu');
print drupal_render(menu_tree_output($tree2));
?>

<div class="clearfix"></div>

<?php print render($page['copyright']); ?>
</div>
</div>
  </div>
</div>




<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->

<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="<?php echo $directory; ?>/js/bootstrap.min.js"></script>

node.tpl.php

<div class="container main-container">
  <div class="row">
 
  <?php
/**
 * Provides child menu & active parent of active parent...
 */



$path = 'node/'.$node->nid.'';
$parent = menu_link_get_preferred($path);
$parameters = array(

    'active_trail' => array($parent['plid']),
    'only_active_trail' => FALSE,
    'min_depth' => $parent['depth']+1,
    'max_depth' => $parent['depth']+1,
    'conditions' => array('plid' => $parent['mlid']),
  );

$children = menu_build_tree($parent['menu_name'], $parameters);

 foreach($children as $child)
{

if($child['link']['depth'] == 3)

{


?>
<div class="services">
<?php print render($page['rates']); ?>
  </div>


    <div class="col-lg-6 col-md-5 col-sm-24 col-xs-24 caluclators-tools">
      <h3>Caluclators and Tools</h3>
    </div>
   
 
   
    <div class="col-lg-18 col-md-24 col-sm-24 col-xs-24">






<ul class="nav nav-tabs tabs-custom" role="tablist" id="myTab">

<!-- Featured Services Tabs start -->

<?php foreach($children as $child)
{

$title1 = $child['link']['link_title'];
$title = str_replace('?','',$child['link']['link_title']);
$path = $child['link']['href'];
$nid = str_replace('node/','',$child['link']['link_path']);
$test = node_load($nid);


 ?>

<li role="presentation">
<a class="<?php echo strtolower(str_replace(' ','_',$title)); ?>" href="#<?php echo strtolower(str_replace(' ','_',$title)); ?>" aria-controls="<?php echo strtolower(str_replace(' ','_',$title)); ?>" role="tab" data-toggle="tab"><?php echo $title; ?></a>
</li>
<?php
}
?>
</ul>
      <div class="tab-content">
     
<?php foreach($children as $child)
{

$title1 = $child['link']['link_title'];
$title = str_replace('?','',$child['link']['link_title']);
$path = $child['link']['href'];
$nid = str_replace('node/','',$child['link']['link_path']);
$test = node_load($nid);


 ?>
 
<div role="tabpanel" class="tab-pane" id="<?php echo strtolower(str_replace(' ','_',$title)); ?>">
<?php
echo $test->body['und']['0']['value'];
?>
</div>
<?php   } ?>
      </div>


      <!--<h2 class="featured-service-title">Featured Service</h2>-->
 
   
    </div>
  </div>
</div>
<div class="container main-container">
  <div class="row">
    <div class="col-lg-8 col-md-8 col-sm-24 col-xs-24">
      <div class="emv-card">
        <h1>EMV Credit Cards</h1>
        <p>Take a minute to tell us what we are doing well or what we are doing not so well Take a minute to tell us what we are doing </p>
        <div class="view-all"><a href="#"><img src="<?php echo $directory; ?>/images/learn-more.png" alt="Learn More" title="Learn More" /></a></div>
      </div>
    </div>
    <div class="col-lg-8 col-md-8 col-sm-24 col-xs-24">
      <div class="emv-card">
        <h1>Low Mortgages Rates</h1>
        <p>Take a minute to tell us what we are doing well or what we are doing not so well Take a minute to tell us what we are doing </p>
        <div class="view-all"><a href="#"><img src="<?php echo $directory; ?>/images/learn-more.png" alt="Learn More" title="Learn More" /></a></div>
      </div>
    </div>
    <div class="col-lg-8 col-md-8 col-sm-24 col-xs-24">
      <div class="emv-card">
        <h1>Auto and Boat Loans</h1>
        <p>Take a minute to tell us what we are doing well or what we are doing not so well Take a minute to tell us what we are doing </p>
        <div class="view-all"><a href="#"><img src="<?php echo $directory; ?>/images/learn-more.png" alt="Learn More" title="Learn More" /></a></div>
      </div>
    </div>
  </div>
</div>

<?php break;  }
if($child['link']['depth'] == 4)

{

?>
<div class="col-lg-2 col-md-2 col-sm-0 col-xs-0"> </div>
  <div class="col-lg-20 col-md-20 col-sm-24 col-xs-24 tabs-custom-two">
     <ul class="nav nav-tabs tabs-custom" role="tablist" id="myTab">

<!-- Featured Services Tabs start -->

<?php foreach($children as $child)
{

$title1 = $child['link']['link_title'];
$title = str_replace('?','',$child['link']['link_title']);
$path = $child['link']['href'];
$nid = str_replace('node/','',$child['link']['link_path']);
$test = node_load($nid);


 ?>

<li role="presentation">
<a class="<?php echo strtolower(str_replace(' ','_',$title)); ?>" href="#<?php echo strtolower(str_replace(' ','_',$title)); ?>" aria-controls="<?php echo strtolower(str_replace(' ','_',$title)); ?>" role="tab" data-toggle="tab"><?php echo $title; ?></a>
</li>
<?php
}
?>
</ul>
      <div class="tab-content">
     
<?php foreach($children as $child)
{

$title1 = $child['link']['link_title'];
$title = str_replace('?','',$child['link']['link_title']);
$path = $child['link']['href'];
$nid = str_replace('node/','',$child['link']['link_path']);
$test = node_load($nid);


 ?>
 
<div role="tabpanel" class="tab-pane" id="<?php echo strtolower(str_replace(' ','_',$title)); ?>">
<?php
echo $test->body['und']['0']['value'];
?>
</div>
<?php   } ?>
      </div>
   
   
    </div>
  <div class="col-lg-2 col-md-2 col-sm-0 col-xs-0"> </div>
  </div>
<?php break;



}
 ?>
<?php
}
?>


<?php
foreach($node->menu_node_links as $nodes)
{
if($nodes->has_children == '0' )
{ ?>
<div class="container main-container">
  <div class="row">
    <div class="col-lg-18 col-md-24 col-sm-24 col-xs-24">




<h2 class="featured-service-title"><?php echo $node->title; ?> </h2>
<?php echo $node->body['und'][0]['value'];

 
     ?>
    </div>
    <div class="col-lg-6 col-md-5 col-sm-24 col-xs-24 caluclators-tools no-top-margin alpha">
      <!--<h3>Caluclators and Tools</h3>-->
      <h2 class="featured-service-title">Caluclators</h2>
      <div class="caluclators-tools-content"></div>
    </div>
  </div>
</div>
<?php
break;
}
}
?>
<?php
/*
foreach($node->menu_node_links as $nodes)
{
if($nodes->menu_name == 'menu-sdfcu-menu' && $nodes->has_children == '0' )
{
echo $node->body['und'][0]['value'];
break;
}
}  */
?>

 <div class="services">
  <?php print render(block_get_blocks_by_region('rates'));  ?>
  </div>
 
  

Template customization

<?php

/**
 * Add body classes if certain regions have content.
 */
function bartik_preprocess_html(&$variables) {
  if (!empty($variables['page']['featured'])) {
    $variables['classes_array'][] = 'featured';
  }

  if (!empty($variables['page']['triptych_first'])
    || !empty($variables['page']['triptych_middle'])
    || !empty($variables['page']['triptych_last'])) {
    $variables['classes_array'][] = 'triptych';
  }

  if (!empty($variables['page']['footer_firstcolumn'])
    || !empty($variables['page']['footer_secondcolumn'])
    || !empty($variables['page']['footer_thirdcolumn'])
    || !empty($variables['page']['footer_fourthcolumn'])) {
    $variables['classes_array'][] = 'footer-columns';
  }

  // Add conditional stylesheets for IE
  drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
  drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
}

/**
 * Override or insert variables into the page template for HTML output.
 */
function sdfcu_process_html(&$variables) {
  // Hook into color.module.
  if (module_exists('color')) {
    _color_html_alter($variables);
  }
}

/**
 * Override or insert variables into the page template.
 */
function sdfcu_process_page(&$variables) {
  // Hook into color.module.
  if (module_exists('color')) {
    _color_page_alter($variables);
  }
  // Always print the site name and slogan, but if they are toggled off, we'll
  // just hide them visually.
  $variables['hide_site_name']   = theme_get_setting('toggle_name') ? FALSE : TRUE;
  $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
  if ($variables['hide_site_name']) {
    // If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
    $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
  }
  if ($variables['hide_site_slogan']) {
    // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
    $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
  }
  // Since the title and the shortcut link are both block level elements,
  // positioning them next to each other is much simpler with a wrapper div.
  if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
    // Add a wrapper div using the title_prefix and title_suffix render elements.
    $variables['title_prefix']['shortcut_wrapper'] = array(
      '#markup' => '<div class="shortcut-wrapper clearfix">',
      '#weight' => 100,
    );
    $variables['title_suffix']['shortcut_wrapper'] = array(
      '#markup' => '</div>',
      '#weight' => -99,
    );
    // Make sure the shortcut link is the first item in title_suffix.
    $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
  }
}

/**
 * Implements hook_preprocess_maintenance_page().
 */
function sdfcu_preprocess_maintenance_page(&$variables) {
  // By default, site_name is set to Drupal if no db connection is available
  // or during site installation. Setting site_name to an empty string makes
  // the site and update pages look cleaner.
  // @see template_preprocess_maintenance_page
  if (!$variables['db_is_active']) {
    $variables['site_name'] = '';
  }
  drupal_add_css(drupal_get_path('theme', 'sdfcu') . '/css/maintenance-page.css');
}

/**
 * Override or insert variables into the maintenance page template.
 */
function sdfcu_process_maintenance_page(&$variables) {
  // Always print the site name and slogan, but if they are toggled off, we'll
  // just hide them visually.
  $variables['hide_site_name']   = theme_get_setting('toggle_name') ? FALSE : TRUE;
  $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
  if ($variables['hide_site_name']) {
    // If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
    $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
  }
  if ($variables['hide_site_slogan']) {
    // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
    $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
  }
}

/**
 * Override or insert variables into the node template.
 */
function sdfcu_preprocess_node(&$variables) {
  if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
    $variables['classes_array'][] = 'node-full';
foreach (array('rates') as $region) {
      $variables[$region] = theme('blocks', $region);
    }
      return $variables;
  }
}

/**
 * Override or insert variables into the block template.
 */
function sdfcu_preprocess_block(&$variables) {
  // In the header region visually hide block titles.
  if ($variables['block']->region == 'header') {
    $variables['title_attributes_array']['class'][] = 'element-invisible';
  }
}

/**
 * Implements theme_menu_tree().
 */
function sdfcu_menu_tree($variables) {
  return '<ul>' . $variables['tree'] . '</ul>';
}


function sdfcu_menu_tree__menu_footer_top_menu(&$variables) {

  return '<ul>' . $variables['tree'] . '</ul>';
}


function sdfcu_menu_link__menu_sdfcu_menu($variables)
{
  $element = $variables['element'];
  $sub_menu = '';

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
 
  // This example is adds the depth class just for a specific menu. Change 'menu-name' to your menu name.
  if ($element['#original_link']['menu_name'] == 'menu-sdfcu-menu') {
if($element['#original_link']['depth'] == 2)
  {
  $class1 = strtolower(str_replace(' ','-',$element['#original_link']['link_title']));
  $class = str_replace('?','',$class1). " menu-level-2";
  return '<li class="'.$class.'">' . $output . $sub_menu . "</li>\n";
  }
if($element['#original_link']['depth'] == 1)
  {
  $class1 = strtolower(str_replace(' ','-',$element['#original_link']['link_title']));
  $class = $class1. " dropdown";
 
  return '<li class="'.$class.'">' . $output .'<b class="caret"></b>'. $sub_menu . '</li>';
 
  }
  if($element['#original_link']['depth'] == 2)
  {
  $class1 = strtolower(str_replace(' ','-',$element['#original_link']['link_title']));
  $class = str_replace('?','',$class1). " menu-level-2";
  return '<li class="'.$class.'">' . $output . $sub_menu . "</li>\n";
  }
if($element['#original_link']['depth'] == 3)
  {
  $class1 = strtolower(str_replace(' ','-',$element['#original_link']['link_title']));
  $class = str_replace('?','',$class1). " menu-level-3";
  return '<li class="'.$class.'">' . $output . $sub_menu . "</li>\n";
  }
if($element['#original_link']['depth'] == 4)
  {
  $class1 = strtolower(str_replace(' ','-',$element['#original_link']['link_title']));
  $class = str_replace('?','',$class1). " menu-level-4";
  return '<li class="'.$class.'">' . $output . $sub_menu . "</li>\n";
  }  
  else {
    return '<li>' . $output . $sub_menu . "</li>\n";
  }

}
  }
 




function sdfcu_menu_link__menu_footer_top_menu($variables)
{
  $element = $variables['element'];
  $sub_menu = '';

  $element['#attributes']['class'][] = 'menu-' . $element['#original_link']['mlid'];

  if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
  $output = l($element['#title'], $element['#href'], $element['#localized_options']);
  return '<li class="col-lg-4 col-md-4 col-sm-12 col-xs-12">' . $output . $sub_menu . '</li>';
}

function sdfcu_menu_link__menu_footer_menu($variables)
{
$element = $variables['element'];
  $sub_menu = '';
 
if ($element['#below']) {
    $sub_menu = drupal_render($element['#below']);
  }
    $element = $variables['element'];
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
if($element['#original_link']['depth'] == 1)
{
return '<li class="col-lg-4 col-md-4 col-sm-12 col-xs-12">' . $output . $sub_menu . '</li>';
}

else
{
return '<li>' . $output . $sub_menu . '</li>';
}
}

/**
 * Implements theme_field__field_type().
 */
function sdfcu_field__taxonomy_term_reference($variables) {
  $output = '';

  // Render the label, if it's not hidden.
  if (!$variables['label_hidden']) {
    $output .= '<h3 class="field-label">' . $variables['label'] . ': </h3>';
  }

  // Render the items.
  $output .= ($variables['element']['#label_display'] == 'inline') ? '<ul class="links inline">' : '<ul class="links">';
  foreach ($variables['items'] as $delta => $item) {
    $output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
  }
  $output .= '</ul>';

  // Render the top-level DIV.
  $output = '<div class="' . $variables['classes'] . (!in_array('clearfix', $variables['classes_array']) ? ' clearfix' : '') . '"' . $variables['attributes'] .'>' . $output . '</div>';

  return $output;
}


function sdfcu_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'search_block_form') {
 
    $form['search_block_form']['#title'] = t('Search'); // Change the text on the label element
    $form['search_block_form']['#title_display'] = 'invisible'; // Toggle label visibilty
    $form['search_block_form']['#size'] = 40;  // define size of the textfield
    $form['search_block_form']['#default_value'] = t('Search'); // Set a default value for the textfield
    $form['actions']['submit']['#value'] = t('GO!'); // Change the text on the submit button
    $form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/images/search-ico.png');

$form['search_block_form']['#prefix']= '<li class="search">';
$form['search_block_form']['#suffix']= "</li>";
    // Add extra attributes to the text box
    $form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Search';}";
    $form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'Search') {this.value = '';}";
    // Prevent user from searching the default text
    $form['#attributes']['onsubmit'] = "if(this.search_block_form.value=='Search'){ alert('Please enter a search'); return false; }";

    // Alternative (HTML5) placeholder attribute instead of using the javascript
    $form['search_block_form']['#attributes']['placeholder'] = t('Search');
  }
 
 
}




  // Helper function used below.
  function _menu_subtree_data($item, $tree) {
    foreach ($tree as $cid => $data) {
      if ($item['mlid'] == $data['link']['mlid']) {
        return array($cid => $data);
      }

      if ($data['below']) {
        $return = _menu_subtree_data($item, $data['below']);
        if ($return) {
          return $return;
        }
      }
    }
    return FALSE;
  }