Drupal maintenance tasks
How important is having a database optimized. Doing some "basic" optimizations like clearing the cache, runing the Drupal cron and a couple of things more, your database can change from having 4 GB to just around 200MB... incredible? Not at all, the importance of maintenance tasks :-)
Which tasks? Mainly:
- Read more about Drupal maintenance tasks
- Log in or register to post comments
Drupal developer links of the week (01-02-2013)
Some interesting links that I have found this week.
- Read more about Drupal developer links of the week (01-02-2013)
- Log in or register to post comments
code reviewed in Drupal Sprint London 2013
steps:
download review tools,
1. coder: http://drupal.org/project/coder
2. php code sniffer: http://drupal.org/node/1419988
3. dreditor: http://drupal.org/project/dreditor
4. paraviewsh (automated tool): http://drupal.org/project/pareviewsh
- Read more about code reviewed in Drupal Sprint London 2013
- Log in or register to post comments
Debug Cron white screen in drupal
Debugging cron issues and errors is one of the most tricky things in Drupal. If you are dealing with a big site, with people adding nodes, inserting content which you can't allways force to be commited in the right way, and things like that, it is not unusual to find a cron broken by some "misterious" node.
Well, it is quite easy to find this "misterious" offender, just logging the cron activity. How, very easy, with my new module "cron_killing_finder".
- Read more about Debug Cron white screen in drupal
- Log in or register to post comments
Validation file in Drupal without theme / template
Sometimes you need to upload files to, for example, validate an affiliate with whom you want to start to work.
The problem, is that these affiliate files need to be "clean", no template, no theme, just the code or validation string which they send.
The solution can be very complicated, like creating a new theme just for a group or a contect of pages... or as simple as creating a node with the string which we need and executing a php code with an exit command. Something like this:
valicationStringLikeUZasdBNf6asdfT2asdfafjpdadf===58QYg==
- Read more about Validation file in Drupal without theme / template
- Log in or register to post comments
Get Drupal fields for a particular content type
Sometimes in Drupal you need to get the fields for a particular content types.
"$type = 'mytype';
$fields = content_fields();
$type_fields = array();
foreach ($fields as $field_name => $field_data)
{
if ($field_data['type_name'] == $type)
{
$type_fields[$field_name] = $field_data;
}
}"
in drupal7 is easier, since we have a direct function:
field_info_instances($entity_type = NULL, $bundle_name = NULL)
- Read more about Get Drupal fields for a particular content type
- Log in or register to post comments
get current drupal theme
very simple:
global $theme_key;
echo $theme_key;
if we need more information, we can use this:
$themes = list_themes();
$theme_object = $themes[$theme_key];
// print all the object fields
var_dump($theme_object);
- Read more about get current drupal theme
- Log in or register to post comments
Apache Solr + Drupal
Download the apachesolr module from drupal.org, and put it in sites/all/modules:
http://drupal.org/project/apachesolr
download solr-php-client, version 22
http://code.google.com/p/solr-php-client/downloads/list
and uncompress it in the apachesolr module directory.
Ready to activate the module, but we will did not installed the Apache server, so the module will not work.
- Read more about Apache Solr + Drupal
- Log in or register to post comments
paging results in Drupal
Paginating the results in Drupal is incredible incredible easy. You just have to remember the two "magic functions":
- pager_query($sql, $count);
- theme('pager',10);
pager_query substitutes the typical db_query. Just something like that:
- // $resource = db_query($sql); // -> old sentence without pager
- $resource = pager_query($sql, $count); // -> pager
Then, we simple come back to the function that is called by our hook_menu, and we change:
- Read more about paging results in Drupal
- Log in or register to post comments
Theming you module
Docs are not allways the best part in programming languages, frameworks or CMS. Sometimes you try to make something and you find problems, just because poor documentation.
It's my situation just now. I was trying to create tpl.php files for a module, and it is really easy... if you follow exactly all the steps.
First, hook_menu:
/**
* Implements hook_menu().
*/
function mymodule_menu() {
$items = array();
/*
- Read more about Theming you module
- Log in or register to post comments