If you need to get a count of how many nodes have a specific tid, there are a few ways of attacking the problem. One is by using views which I find overkill for this situation. You could use EntityFieldQuery which is a good option. But for this demo, I'm going to...
Read more
Show subset or subcategory of a Drupal menu
Footer menus aren't as popular as they used to be, but still used often for SEO. You may not want to include the entire menu on the footer, maybe just a section or a subcategory. Here is one way of doing that.
Read more
Modifying browser history and url using jQuery
You open a popup and actually want the browser url to reflect the popup/overlay url. You do this for multiple reasons, but mainly for SEO and social media links. It also allows the visitor to use the 'back' button and have your page react using AJAX instead of actually reloading the previous page.
Here's...
Read more
How to check for previous value when saving a node in Drupal
When you save a node in Drupal 7, hook_node_presave is there to modify values before the node is saved. Also available are the 'original' values so you can compare values from before the edit to after the edit. Can come in handy if you need to trigger some processes when values are changed...
Read more
How to abort a jQuery ajax call before starting a new call
Sometimes you need to trigger an action based on keyup (or any other kind of key stroke action). Usually not a big deal to trigger an action on every key stroke, but if that action triggers an ajax call, you can have many ajax calls running if you're a fast typer :)
So its a...
Read more
Add your own custom user permissions in Drupal 7
Say you created a module that has a page that only certain user roles should be able to access. If you're not using Panels/Page Manager (which can limit per user role) and you're using your own hook_menu item, you'll need to come up with your own permission that will show up on /admin/people/permissions. ...
Read more
Using db_select with conditional statements in Drupal 7
While the debate never ends about using db_select versus db_query...some say db_select is slower and db_query should be used for simple queries, but there are obvious advantages to db_select with its extenders and much more.
Whatever your decision, here is one case where db_select is super nice. Instead of building the query string in a variable...
Read more
Allow other functions to alter your data in Drupal 7
You created a function and maybe you want other modules to be able to go in and modify data as needed. Maybe you're returning a list of links and you want other modules to add their own links if needed. drupal_alter is one way of accomplishing this.
Read more
Using the Services module in Drupal 7 to create a REST API
Adding an API to your Drupal site doesn't have to be difficult, well...not too difficult. Using the Services module removes a lot of the work needed and sets you up for an easy implementation. Its especially nice with its hooks and it outputs everything in json format and handles error messaging.
I won't get...
Read more
Drupal caching with cache_get , cache_set , and cache_clear_all
We all know Drupal is a little 'heavy' when it comes to database queries. Using caching for some of your data can greatly improve load times and reduce server loads. Custom caching can be used for a variety of reasons. I like to use it for user-specific sections that Drupal doesn't like...
Read more