Custom Module Code...Time to Come Clean

Events happening in the community are now at Drupal community events on www.drupal.org.
Summitt Dweller's picture

I've written a function that accepts a user ID and pulls associated teacher profile data (courtesy title, first name, last name, etc.) to display a teacher's name in 'proper' school form. For instance, my username of Mark McFate appears in key places (where students have access) on my site as simply "Mr. McFate". The function is named "stc_user_profile_title" and was intended to be part of my "stc" custom module. The function is currently called from a few templates in my theme and it works nicely.

However, I've had to move the function out of my custom module and place it at the end of core's /includes/common.inc in order to make it recognizable in my theme.

My question is... How and where do I properly name or include this function so that it can be part of my custom module and still be callable from my theme templates?

Thanks in advance for any insight here.

Comments

More info please...

cgapperi's picture

Can you give us more information on your problem? Code for the function and name of your custom module at least would be helpful. You should be able to make what you are trying to do happen in your custom module. I try to not edit anything in core, as it makes for headaches during updating.

Resolved

Summitt Dweller's picture

I got it working now...not sure how though? My custom module name is "STC" and I named the function "stc_format_user_name". It's called, I believe from my custom theme called "Go Big Blue".

When I initially created this function (in Drupal 6.15?) and included it in my custom mod I would get run-time errors indicating that it wasn't available (or something to that effect). I subsequently moved it out of my custom mod and into common.inc in order to make it work.

Last week I moved it back into my custom mod just to see if I could get to the bottom of the issue...and it just works. Removed the copy from common.inc and it still works. Pretty much what I hoped would happen from the start. No idea what's changed.

Mark

Clear your cache...

cgapperi's picture

Glad to hear that it is working.

One thing before you can be sure that it is working, is you might want to clear your cache. It very well may be that the changes you made to core are still being cached and that's why it is still working. The other reason it could be working now and didn't before is that your cache has been cleared now and wasn't before. I can't stress enough to clear your cache as you go along. I have spent way too much time troubleshooting problems before I remembered to clear my cache. See the comments here, http://groups.drupal.org/node/86904, for some recommended modules to install to assist with housekeeping duties like clearing the cache.

Another step that sometimes helps is to run the update.php when something isn't working like you expected it to.

Central Iowa Drupal Users Group

Group categories

Category

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: