HTML playground for drupal

Recently I had to build this. It’s a simple little app that uses the forms API. Think w3schools.com “try it yourself.”

function sg_games_menu(){

 

        $items[‘html-sandbox’] = array(

             ‘title’ => t(‘HTML sandbox’),

             ‘page callback’ => ‘sg_games_html’,

             ‘access arguments’ => array(‘access [...]

Continue Reading...

How to: Force download of links in Magento

It’s an easy fix. I’ll tell you about the hack way to do it, if you like doing it the right way have fun creating 7-8 files.

Continue Reading...

Pseudo Random Algorithm

Ever wanted to program something that looks like a random outcome, but comes out the same way every time based on some kind of input? Here is one way. The modulus (%) operator is the key because it produces an output that seems to vary randomly. I had to implement something like this in Javascript.

function [...]

Continue Reading...

R integration with PHP

Recently, I needed to do some statistical tests on data from within a Drupal Module. Having found no PHP libraries suitable for the task, I decided to try and run code in R from within PHP. This post helped out a great deal.
As far as I can tell, the only way to do this is [...]

Continue Reading...

How to: Make sure Buddypress loads first

Often, it doesn’t matter whether your Buddypress plugin loads before or after Buddypress. However, if you are using groups API, or extending other Buddypress plugins, your class extensions require that Buddypress be loaded beforehand. Functions hooked into actions that occur before Buddypress loads that use Buddypress functions will cause problems as well if the load [...]

Continue Reading...

How to: use email addresses as usernames in Buddypress

Just spent about 5 hours on this one, enjoy …
I’ve seen this question come up on a lot of forums – people want to use email addresses as usernames in Buddypress. It makes sense – emails are easy to remember. But Buddypress has made this difficult to do. Andy Peatling added the following constant to [...]

Continue Reading...

How to: alter the content of activity items

It puzzled me at first when I discovered that activity items are formatted as html before they are stored in the database. This reduces the workload upon retrieval but makes it almost impossible to edit the content of old entries.
Fortunately it is quite easy to change the way activity items are stored in the database. [...]

Continue Reading...

How to: Get Ajax working in Buddypress

Ajax can really streamline a site’s user experience. The WordPress/WPMU back-end owes much of its ease of use to the presence of many dynamic menus and feedback notices. No one has had time to implement much of this for Buddypress, but I’m going to show you how to put use Ajax in your Buddypress plugins.
Its [...]

Continue Reading...

How to: Restrict access to activity feeds

This will make it so that if some one does not have a logged in cookie, they cannot view the content of any activity feed.

 

function restrict_feeds(){

        if (!is_user_logged_in()) {

                remove_action( ‘wp’, ‘bp_activity_action_sitewide_feed’, 3 );

                remove_action( ‘wp’, ‘bp_activity_action_personal_feed’, [...]

Continue Reading...

Object orientation and natural language

If I had to pick one word that said the most about information processing and presentation, I would choose “abstraction.” Its Latin roots give it a derivative meaning of “to drag out;” it might be more useful to think of it as meaning “to pull out” or “to distill.” Often we think of abstraction as [...]

Continue Reading...