HTML and CMS blog

Fix missing body images when site moved in subdirectory
/**
 * When site move to subdirectory, pictures, added in WYSIWYG, return old address
 * this small js fix it.
 */

(function($){
  $(document).ready(function() {
  
    if (Drupal.settings.basePath != '/') {
      $("body.page-node article .entry-content img").each(function() {
        var src = $(this).attr('src');
        $(this).attr('src', Drupal.settings.basePath + src);
      });
    }
  });
})(jQuery.noConflict());
by Anonymous Tags: Drupal, jQuery
Add numerious for each wordpress widget in sidebar
<?php
/**
 * Add numerious for each widget in sidebar
 */
function htmlandcms_widget_classes($params) {
  static $classes;
  if (!isset($classes[$params[0]['id']])) {
    $classes[$params[0]['id']] = 1;
  } else {
    $classes[$params[0]['id']] += 1;
  }
  $params[0]['before_widget'] = "<div id='{$params[0]['id']}-{$classes[$params[0]['id']]}'>" . $params[0]['before_widget'];
  $params[0]['after_widget'] = $params[0]['after_widget'] . "</div>";
  return $params;
}
add_filter('dynamic_sidebar_params', 'htmlandcms_widget_classes');

by Anonymous Tags: Wordpress
Custom rewrite rules with pagination in wordpress

Sometimes we need to use $_GET params in custom pages for something like custom filter.
In my case i must create page with custom query_posts, filter this posts and glossary. In glossary links must look like site.com/glossary/a/ or site.com/glossary/b/

First we need to create page with slug 'glossary' and set permalink to Post name.
In theme directory copy page.php to page-glossary.php and put this code

by Anonymous Tags: Wordpress, rewrite
Add rel="fancybox" to wordpress gallery

If you need to add rel="fancybox" in the standard wordpress gallery, then this is a lesson for you.
Firstly what we need to do, its enqueue fancybox script, add image sizes for thumbnail and big picture and change implementation of gallery shortcode by default.
So let's do it.

by Anonymous Tags: Wordpress, gallery, fancybox
How to create easy antibot registration module for Drupal 7

Any project should be protected from automatic registration, One of wellknown solutions is using CAPTCHA.  There are a lot of kinds of CAPTCHA and most part of them were designed for very big projects wich could be affected by directed spam attack of competitors or other "enthusiasts". On simple sites which are not as famous as facebook or twitter we don't need such difficult protection. 

by Anonymous
Wordpress random comment with link to post

Task to show random comment with link to post. The decision below. First we get all approved comments. If we have comments we get random number among of existing, then we print comment content, and put link to commented post. Thats all, we spent some time to do it and we hope our solution will be useful for you.   

by coordinator
How to save pdf file in public files directory in drupal 7

Sometimes we need to save pdf file in directory. In drupal for this purpose we can use print-email-pdf module wich give us pdf file when we follow url  yoursite.com/printpdf/nid. We can easily grab the content of this file using file_get_contents() function. You should look at code example:

by Anonymous Tags: Drupal
Update taxonomy aliases with views bulk operation in Drupal 6

Hi everybody, recently faced with the fact that you need to update thousands of aliases to content, taxonomy terms, and users. 
Everything is good only if it did not have to do for Drupal 6. 
The solution was found immediately.
Download and install the module and create three views_bulk_operations display. 
The first and the second is the list of contents and a list of users, respectively. In the display settings set bulk operations and select "Update URL alias" and set to use the batch api.
But for taxonomy terms no field update paths aliases.

by Anonymous Tags: bulk operations, Drupal 6, pathauto, views

Pages