• Awning Works 1
  • Socaz 2
  • Socaz 1
  • Randy Montana 3
  • Randy Montana 2
  • Randy Montana 1
  • Rodgers & Hammerstein 3
  • Rodgers & Hammerstein 2
  • Rodgers and Hammerstein 1
  • Love Fine Art
  • Sep
  • 16
  • 2011

How to Get the Path ID (pid) for a Node’s Path Alias in Drupal 7

Posted by admin In Drupal 6 & Drupal 7, How To, PHP | No Comments »

After searching the internet I found nothing satisfactory for simply finding the Path ID for a node’s alias.

I need this this so that I could programmatic update a node alias in a way that keeps the Drupal site installation updated system wide without conflicts. So, anyway here is a simple function to find the alias path id for a given node.

By the way, if you got to   Home » Administration » Configuration » Search and metadata  and then hover over the edit link on the row of the alias in question, you will see the path is in the url.

<?php

/**
*
* Returns the path alias id for a given alias.
*
* $nid
* int    The node id
*
*/
function pathdata_get_pid( $nid ) {
if ( isset($nid)  && is_numeric($nid) ) {

    $source  = ‘node/’. $nid ;
$query = db_select(‘url_alias’, ‘ua’);
$result = $query->fields(‘ua’ )
->condition( ‘source’, $source , ‘=’)
->execute();
$data = $result->fetchAssoc();
return $data['pid'];
}
else {
return 0;
}
}

?>

 

 

  • Jan
  • 24
  • 2011

How to Get Port 80 Working on MAMP

Posted by admin In Apache, How To, MAMP | No Comments »

Thanks James for the following advice:

Got to step 7 and it worked for me!

1) Take some tea
2) Follow these instructions:
3) Disable Web Sharing in System Preferences
4) Open MAMP, make sure servers are stopped
5) Open Preferences panel in MAMP
6)  Switch to Ports, set Apache Port to 80. Click OK.
7)  Try starting your servers.
* If it doesn’t work, manually review your httpd.conf file (within the MAMP application folder) and make sure that there are no active references to 8888

BTW: you can turn Web Sharing back on after these steps and it will keep working on Port 80.

  • Sep
  • 13
  • 2010

When using hook_form_alter on the user.module’s form

I recently spent some time scratching my head and trying to troubleshoot some very odd behavior when using hook_form-alter() on the user_form. The checkbox for the “agree” to the legal ease stopped working for one thing. In addition to that, the form refused to redirect even though I was doing everything right. I quadruple checked my syntax and methods over and over. What could it be?!

As it turns out, it was a permissions problem. Dugh! I had set the access to be true if the user was logged in as a certain role. However, as we all know the user form only work for anonymous user so that they can log in. If the user is logged in, it does not allow access. By trying to use hook_form_alter() with a permissions conflict the resulting form was understandably misbehaving.

So there you have it. Another honest admission of a lesson learned by trial and error. I hope this will save someone a few hours in their efforts.

  • Sep
  • 29
  • 2009

How to edit scanned photos quickly!

Posted by Reniroo In How To, Photoshop Notes, Web Design | No Comments »
How to edit scanned photos quickly!

Photoshop scanned multiple images

Rather than scanning one photo at a time to create digital files of older photos, I scanned multiple photos at once.  The re

sult was a page of pictures in Photoshop linked as one file.  The dilema as to how to separate them individually to work with and save them, appeared to be a tedious chore of using the marqee tool to cut them out, creating

layers of various pictures….you get the idea!  Much to my joyous surprise, Photoshop has a very amazing tool under the File pull down menu.  Simply go to Automate then Crop and Straighten.  Make sure you are on the root layer containing all your pictures and Photoshop does the rest.  Each picture will be a separate file to work

After process to separate photos

with.  When scanning, make sure there is a space around each picture to make

it easier for Photoshop to differentiate the photos.  Once you have made your adjustments or manipulated your photos, do not forget to name and save your photo

before closing.  Now you are ready to archive all those older photographs and priceless memories!

  • May
  • 07
  • 2009

How to Protect Against SQL Injection

Posted by admin In AJAX, How To, MySQL, PHP, Web Security | No Comments »
How to Protect Against SQL Injection

One of the most common web security problems is SQL Injection. As the name implies, SQL injections works by introducing malicious SQL code where it doesn’t belong. Since it is SQL code you could probably guess that the attacker “injects” his poison via database queries. Web developers often pass some sort of variable to their database queries. Very common are variables that are influenced by user input. User input, to variable, then to query,- get it? So, there is a need for a way of eliminating the user’s ability to manipulate the variable in any way that could effect the query.

What Happens With SQL Injection

By passing an unexpected string of code into a user input, such a form, an attacker send damaging code that causes an otherwise good query to go haywire. For example:

  • Apr
  • 30
  • 2009

How to Create a User Interface Style Guide

I frequently peruse for tidbits of inspiration. There are so many more beautiful, competent site designs than there used to be.  Setting aside a nice design and well thought out code, there is a common thread to be found that ties all of them together. They are all new.

Along with site design that is lean and beautiful come a few frustrations, however. Many designers find that after publishing an elegant user interface, they return to their client’s site a few months later only to find it cluttered up with gaudy graphics and inappropriate colors.

One of the ways to keep this phenomenon under control is by providing good documentation.

Flickr Stream