• 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
  • Apr
  • 22
  • 2011

DRUPAL: Broken Teaser (or body) Text Showing Up at the Top of Page.

Posted by admin In Drupal 6 & Drupal 7, PHP | No Comments »
DRUPAL: Broken Teaser (or body) Text Showing Up at the Top of Page.

The output of some of the webpages was spilling out at the top of the page as broken HTML. I knew that the body or teaser was somehow getting printed out prior to the body loading. At first, a friend suggested that the problem was unfiltered use of the $vars['node']->body in the Organic Groups module. It turned out to be unfiltered output of the $vars['node']->teaser (could just as well been the body) was being used by some meta tag creating logic for a facebook comment button. The broken code was in the template.php file.

The fix was simple. All I had to do was add PHP’s strip_tags() function to filter out the HTML that was finding its way into the META tag like this:

strip-tags-fix-node-teaser

Problem solved! I hope this was helpful for someone.

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

  • Apr
  • 10
  • 2010

Drupal Comments In A Block

Drupal Comments In A Block

Why would you need to put Drupal comments into a block?  Well, recently I was working with another developer that decided to use Quick Tabs to create a menu that would show the current content type’s comments. Quick Tabs uses blocks, so there is one reason I can think of.

Ok, so getting the content type’s comments into a block is pretty easy once you know how.

This method will require you to use PHP code from within the block you will create to show the comments. So the first thing is to make sure that this is possible by going to site building and then modules and turning on the PHP Filter under the category of Core Optional (if it is not already on that is).

NOTE: Check at admin/settings/filters to be sure that only trusted roles can use the PHP filter, otherwise your web site could be vulnerable to attack. By default, only the administrator can use this filter.

Create a new block and select a region for it. Put the following code on the body textarea:

comments in block php code for drupal

Do not forget to select the PHP filter from the list of the input filters. After entering the rest of the settings for your block click save.

Now your new block should be ready to assign to whatever region you want. If the page you load has comments related to it. They should now appear via the block.

The arg() funtion may seem a bit cryptic if you’re new to Drupal. Here is a quick explanation from George Notaras in his post: Drupal Tip: List a node’s taxonomy terms inside a Block which I found helpful in compiling this information.

“Now to some technical details about arg(0) and arg(1), which probably seem a bit cryptic to a user that is not experienced with Drupal (like me). Assume we have the following URL to a node: www.example.org/node/23, which means that the path to the page is /node/23. Well, arg(0) is the node part and arg(1) is the second part; 23 that is. Read about the arg() function.”

I hope this was helpful.

  • Feb
  • 13
  • 2010

Navicat Connetion with MAMP Pro

Posted by admin In Drupal 6 & Drupal 7, MAMP, MySQL | No Comments »
Navicat Connetion with MAMP Pro

MAMP Pro has a lot of nice features. However, this means it changes things up a bit. How you make a connection with Navicat is one such example. So here is a quick helper post get Navicat up and running with MAMP PRo.

1) Add your information to the “Connection Properties” Pane as you normally would.

Navicat Pane -General

2) Click on the “Advanced” pane and check the box next to “Use socket for localhost connection.”

3) Then for the “Socket File Path” field type the following path.

/Applications/MAMP/tmp/mysql/mysql.sock

The “Advanced” Pane should now look like this:

Navicat Advanced Pane

Click “OK” and you should be all set.

Navicat Connection Sucessfull

I hope this helps. Please feel free to make comments.

  • Oct
  • 02
  • 2009

Drupal Notes

Posted by admin In Drupal 6 & Drupal 7 | No Comments »

It has been said that Drupal is well documented. While it true that Drupal is “well documented”, it can also be said the Drupal is not “documented well”. There are plenty of documents describing functions and modules and their purpose. However, for those of us that are trying to learn a new system, albeit an excellent one, the whole thing can be rather abstract. For example, I have been spending the last 8 hours learning about the Drupal Form API. I easily grasped the concept of putting the form elements into arrays and construction the form from the array. I understand that the drupal_get_form($form_id) is the “key” function in the Drupal Form API. I even picked up on the the fact that the name of the function that I am supposed to create to build the form’s array of elements will be the name of the form id. But I still struggle with things like say, where do I use the function to build the form? In the template.php file? In the module? I’m not opposed to a little trial and error but sometimes I fill like a blind-folded bull in a china shop with the fire sprinklers gone off ( not to imply that all china shops have fire sprinklers).

So this blog will attempt to simply the otherwise abstract and “well documented” Drupal platform in a way that I and/or people like me (who like to be told how things work and where to put them) can understand.

If you find any great resources that lean toward a lot more hand holding let me know, I’ll be happy to link to them from here.

  • Sep
  • 25
  • 2009

Schema Data Structure Documentation in Drupal

I have been working on a project on the Drupal 6 platform that requires the web application to recognize dynamically created sub-domains so the functionality of the database can be adjusted according to what sub-domain is in the current URL.

To get Drupal 6 to do this, I am creating a custom module. One of the things I have learned about creating a custom module in Drupal 6 is the implementation of the module’s “install” file.

If you create a module named say,  my_module.module then the module’s install file name would be  my_module.install and will reside in the directory named my_module located at….

my_site/sites/all/modules/my_module

Drupal 6 Module Install File Documentation

The  .install file will be run by Drupal 6 the 1st time my_module has been enabled. The my_module.install file will then be used to run setup procedures as stipulated by your module. The most common task for the my_module.install file to perform is creating database tables and fields. There is no special syntax for the install file. It is simply a PHP file with a .install extension to properly identify it to the Drupal 6 platform.

There is special function used in the .install file called hook_schema(). Where hook would be replaced by the name of your module. For example, if  the module you create is named my_module, then you would create a PHP file and name it my_module.install. Inside that file you will create a function named  my_module_schema(). The my_module_schema() function is used to create arrays representingthe database tables you wish the module to create in the Drupal database. You can see how this works here.

Why do it this way?

Once you build the Drupal API Schema there is no more need for  separate CREATE TABLE or ALTER TABLE statements on each database. As a module developer, you only need to create a schema structure and/or use the Drupal Schema API functions, and Drupal takes care of the rest. This greatly simplifies  writing install and update functions.

This way of creating the module install files also allows for support in multiple database platforms.

According to Drupal’s Blog this also allows for “Several advanced capabilities, such as incremental database updates, a simple and consistent CRUD API, form scaffolding, simpler CCK and Views, schema and data validation, become much easier to implement in future enhancements.”

Schema Data Structure Documentation by Drupal

Flickr Stream