Drupal Blog

User login

Create an ubercart order programmatically and update address and products.

One of my latests tasks was to allow a link that would take a user id and a node id as an argument, and automatically create a new order that would have some fields pre populated and ready for further editing. Scope is to use the user id as the client that does the order and to automatically select the product depending on the taxonomy term of the provided node.

In my case I offer a series of links through a custom view template, that uses data from each row results to built the link.

Here is the code for my module, hopefully it will be useful for someone:


blog:

Remove duplicate entries from views results... the hard way.

In some cases it is seems impossible to get rid of the duplicate entries that views return in the output.
Not an elegant way, but this small module would do the trick...

So let's create a module the usual way, and put the following code in the .module file.
This one is called remove_duplicates.


<?php
function <MY_MODULE>_views_pre_render(&$view)
{
 
$used_nids = array();

          foreach (
$view->result as $row)
      {
        if (!
in_array($row->nid, $used_nids))
        {
         
$new_view_result[] = $row;
         
$used_nids[] = $row->nid;
        }
?>

Drupal - Load user's Content Profile, given the UID

There are so many reasons to use Content Profile instead of the user's core profile. For once, profiles are created as separate nodes and therefore the full flexibility of CCK and VIews come in the game. This way it is possible to build some really sophisticated profiles, which is usually what is needed for any website.

I had to look around for an easy solution on how to load the user's content profile programmatically, so the following might come in helpful.

How to test cron in Centos

Here you can find some simple tests that would confirm the smooth functionality of your crontab.

Test if cron is running

Type the following command:

ps ax | grep cron 

Make sure that cron shows up. Expected output should be something like

[konordo@konordoserv]# ps ax | grep cron
1185 pts/1    S+     0:00 grep cron
1771 ?        Ss     0:00 crond

Test if cron is working

Add the following entry to your crontab. To do so, enter the command

crontab -e

How to use datepicker pop up in a form field in a custom module?

Ever needed to use datepicker pop up in a custom module? That would be the most usable way to allow users to choose a date.

Here is the code to be used in the form function:

Pages

Subscribe to Drupal Blog