PHP

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....

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)

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 !

Drupal 7 Custom form with ajex for use in custom table

so you want to use drupal to render a form but submit that data to a custom table you defind or other database on your server* 
in my case i had a custom created table called `user` but my main drupal database was using a prefix ... so all my querys were failing if your database does not have a prefix then skip ahead :

first is you need: to change your settings file settings.php...

Add Ubercart Feature Automaticly

I had an issue where we needed to have add ubercart feature on every product - and did not want to make my client add the new feature every time as would take too much time
as there is now way to set default features  in this case I needed to add Price Quotes   as this project was using ubercart as a quote system , so what was a person to do ?
the anwser is the rules module !

Create a new rule run when content is created and type is "product"... Exacute custom php ...