Drupal

Drupal & infusionsoft php example

Working with drupal and infusionsoft ,  so your client has infusionsoft and want to interact with your drupal site .
so you installed the infusionsoft module and need to do custom things that "cant" be done with rules or (d6 conditional actions)  Like checking if user has a tag or if exists in infusionsoft or what ?! 
so then you go looking for examples of php & infusionsoft and find a lot of crap !  So lets have a look at this,

First create a custom module:
example mymodule.info

Custom social share module d6 and d7:

Have a look at the bottom of this page ...see the social widget ?
well  it is a module  I made for  drupal 6 and drupal 7

That provides social like actions with little to no JavaScript overhead ... however it is 100% custom !

That means you can do whatever you want with it ... 

Want  10000000 likes on face book ? Just go type it in !  “Looks” like you are social media king !

Download:

Drupal Show block on specific pages php example

Using drupals php imput for block Visibility settings ..  "Show if the following PHP code returns TRUE (PHP-mode, experts only)."  ... what this means  is
that you can use php to show the block ...well dahhhhhhh.

here is the basic idea:

<?php
$nid = arg(1);

if($nid =="20"){
return true;
}else{
return false;
}

?>

 

Well this is a stupid example I know but it just shows you if it returns true the block will show ... so how about this for an example....

Basic intro to twig for drupal 8

Well you seen the news with drupal 8 the way we theme is going to be different using twig

this is a basic play with twig in Drupal8 ,

Ok to play you need drupal 8 ! that is for starters so just git it.

You will also want to add admin/config/development/performance
To your shortcuts or open in another tab. as drupal 8 theme settings ~right now anyway~ do not have the rebuild theme cache on every page , which sucks because when you make a change to the template you need to clear the sites cache to see if things worked out.

Drupal webform in shadowbox

Some tims you want to make a webform in a pop up shadow box or light box ...well that is cool here is how you set that up:
1) Make the drupal webform the normal way and note the page id :
2) Copy your page-node.tpl.php and change it to page-node-YOURID.tpl.php (example page-node-38.tpl.php
3) in your themes template.php add this function so you can template pages by id: (change "themename" to your themes name)

Easy drupal redirect after login

This is hands down the easiest way you can redirect (drupal) users to a different url after log in: make a folder called "customredirect" inside it male a "customredirect.info" file and a customredirect.module file contents of customredirect.info

name = customredirect
description = "this is the redirect to diffirent page on user login"
package = other
core = 7.x

Contents of customredirect.module

Drupal7 work with jquery in a module

I agree that there are better ways to do this but some times you need just a few functions or need php to help create a jquery function inside a module 

	$output ='<script>
	(function($) {
Drupal.behaviors.myBehavior = {
  attach: function (context, settings) {
    //code starts
 $(document).ready(function() {
	 alert("hello");
 });
 
    //code ends
  }
};
})(jQuery);
	</script>';

Drupal 7 hook form alter validation example

ok so you are making a content type and you want to add a text field (or any type) and you set it all up then bang it hits you you need some extra validation on that field no big deal !
you need the field name ..."Machine name"  (see admin/structure/types/manage/TYPE/fields) and the form id  (create content ..the type with your field view sourse ..lookfor form_id) then you can module it up !