Галерея сайтов

16:27

Ресурс представляет из себя галерею сайтов, выполненных Drupal-разработчиками и, соответственно, на CMS/CMF Drupal.

Принимаются проекты, удовлетворяющие нашим не сложным правилам. Разработка сайта подразумевает под собой внешний вид (дизайн и вёрстка) и программные решения (например, написание и интеграция модулей).

Для удобства добавления сайта, сделаны категории по тематике сайта и выбор из цветовых решений. Сайт может быть добавлен в несколько категорий. Для добавления сайта требуется регистрация.

Сайты сортируются по дате добавления. Для удобства есть сортировка по рейтингу и алфавиту.

Ссылка

Оптимизация Drupal

12:50

Drupal – довольная распространённая CMS и это отложило на неё свой отпечаток – базовая поставка Drupal является не готовым решением для определённого вида сайта, а фундаментом для его создания. Существуют “сборки” на базе Drupal специализированные под определённые виды сайтов, например: новостные сайты. Но подобные сборки в данный момент мало распространены и плохо поддерживаются. В связи с этим при создании Интернет сайта на основе стандартной поставки Drupal используется большое количество готовых дополнительные модулей и тем оформления для Drupal, либо разрабатываются новые модули и темы специально для создаваемого Интернет сайта.

Далее

И снова о сборках

10:48

Несколько месяцев назад, говоря о рынке плагинов для коммерческих CMS, я мимоходом упомянул про “сборки” открытых систем управления сайтами. При том, что работал я со многими (за спиной несколько десятков проектов различного масштаба на SharePoint, Битриксе, Юми, Wordpress, Drupal, нескольких “студийных” и просто самописных системах), больше всего, несмотря на свою прожорливость, мне нравится именно Друпал. Поэтому просто перечислю несколько интересных сборок на нём, предназначенных для различных задач.

Далее

Handling drupal_set_message for anonymous users

00:11

A. I am facing this very specific problem, Any help would be appreciated.

Everything was working fine untill recently. Now I do not get the New Account Creation Notification on Screen that is displayed to the user. The email gets sent to the user email id but on the screen the user does not come to know that is registration is complete and successfull.

Same for the Forget Password section.

All other messages given by 'drupal_set_message' work. The problem is with these 2 specific messages.
1. New Account Creation Notification on Screen
2. Password Reset Notification on Screen

The only thing that has changed in recent times with the site is that I happened to upgrade the PHP on the server to PHP 5.1.6.

Does that cause any problem?

Please help.

Thanks.

------------------------------------
Q. Somehow the anonymous user was deleted from the database. So check to see if you have a uid of 0 still there. If it isn't there, put it back. That cleared up this issue for me. Here is the sql to do it. The question here is, where did that user go, how did it get deleted?

INSERT INTO users (uid, name, mail) VALUES ('0', '', '');
INSERT INTO users_roles (uid, rid) VALUES (0, 1);

I hope this helps someone avoid a long bug hunt.

---------------------------------------

Worked perfectly for us. A user delete-statement deleted to many users, in our case also the anonymous user.
But when we inserted the user with the insert-statement from above, the new anonymous user got inserted with the uid 6412 or so (because of the auto increment).

So we just changed the uid to 0, and everything worked like a charm.

Thanks a lot.

Далее

Выполнить PHP-код на сайте

00:59

Варианты

Выполнить код (сниппет) можно:

  • В блоке
  • В блоке Execute PHP модуля Devel
  • На странице
  • В отдельном файле



Далее »

Drupal + PHP - How To Auto-Truncate Content At The End Of A Word

00:40

The problem:
Whilst working on an aggregation site recently I needed to find a way to truncate the length of aggregated posts so that they only showed the first 200 or so characters of the post. However, I also wanted the split point in the post to occur at the end of a whole word, as opposed to part way through a word, and add some visual indication that there was more still to read.

The solution:

More »

Basic Next/Previous Navigation For Nodes

22:18

When viewing a node, I wanted the ability to page through to the next and previous article.

  • Code is abstracted out into 2 different functions.
  • You can specify the text to be used for the generated links.
  • Uses l() instead of hardcoding directly generating the links using $nid. l() uses aliases if available and therefore generated links are consistent with the rest of the site.
  • Uses a few class attributes to generated links so they can be styled.

These 2 functions (plus maybe a lot of other similar functions) can be abstracted out into a module.

  1. Create a file called template.php in your theme's folder if it does not already exist, assuming that theme is PHPTemplate-based.
  2. Copy the 2 functions next_node() and previous_node() into template.php. Copy the functions along with their complete definitions i.e. the whole body not only the function names. Make sure the functions are withing <?php and ?> tags.
  3. Copy the code snippet to the place in node.tpl.php where you want the links to appear. These links should appear only when a node is view in its entirety so put them in a if($page!=0).

For themes using other engines you will have to read the appropriate documentation to know where to put the code.

<?php
   
/**
     * Enables theme developers to include a link to the node of the same type
     * that comes immediately after the the node being currently viewed.
     *
     * A node has to be published and promoted to the front page to
     * qualify as the 'next node'. Unpublished and nodes not promoted
     * to front page are not considered.  Access control is respected.
     *
     * Theme developers would normally use this in the template for a node.
     *   
     * @param $node
     *     node whose next node is to be found.
     * @param $next_node_text
     *   The text for the link that will be created. If no text is given
     *     then the title of the next node is used.
     * @param $prepend_text
     *     Text to be prepended to the created link. It is not a part of the link.
     * @param $append_text
     *     Text to be appended to the created link. It is not a part of the link.
     *
     */  
   
function next_node($node, $next_node_text=NULL, $prepend_text=NULL, $append_text=NULL)
    {  
       
$query = db_rewrite_sql("SELECT nid, title FROM {node} WHERE created > '%s' AND status=1 and promote=1 AND type='%s' ORDER BY created ASC LIMIT 1", "node", "nid");
       
       
$result = db_query($query, $node->created, $node->type);

      
$next_node = db_fetch_object($result);

        if(!
$next_node_text) // If next_node_text is not specified then use the next node's title as the text for the link.
       
{
           
$next_node_text = $next_node->title;      
        }
      
        if(
$next_node->nid!=NULL)
        {
            return
$prepend_text.l($next_node_text, 'node/'.$next_node->nid, array('title'=>'Go to the next post "'.$next_node_text.'"', 'class'=>'goto-previous-node')).$append_text;
        }
        else
// There is no next node for this node...
       
{
            return
NULL;
        }
    }

   
/**
     * Enables theme developers to include a link to the node of same type
     * that comes immediately before the the node being currently viewed.
     *
     * A node has to be published and promoted to the front page to
     * qualify as the 'previous node'. Unpublished and nodes not promoted
     * to front page are not considered.  Access control is respected.
     *
     * Theme developers would normally use this in the template for a node.
     *   
     * @param $node
     *     node whose next node is to be found.
     * @param $previous_node_text
     *   The text for the link that will be created. If no text is given
     *     then the title of the previous node is used.
     * @param $prepend_text
     *     Text to be prepended to the created link. It is not a part of the link.
     * @param $append_text
     *     Text to be appended to the created link. It is not a part of the link.
     *
     */
   
function previous_node($node, $previous_node_text=NULL, $prepend_text=NULL, $append_text=NULL)
    {  

       
$query = db_rewrite_sql("SELECT nid, title FROM {node} WHERE created < '%s' AND status=1 and promote=1 AND type='%s' ORDER BY created DESC LIMIT 1", "node", "nid");
       
       
$result = db_query($query, $node->created, $node->type);

      
$previous_node = db_fetch_object($result);

        if(!
$previous_node_text) // If previous_node_text is not specified then use the previous node's title as the text for the link.
       
{
           
$previous_node_text = $previous_node->title;      
        }
      
        if(
$previous_node->nid!=NULL)
        {
            return
$prepend_text.l($previous_node_text, 'node/'.$previous_node->nid, array('title'=>'Go to the previous post "'.$previous_node_text.'"', 'class'=>'goto-previous-node')).$append_text;
        }
        else
// This node does not have a previous node...
       
{
            return
NULL;
        }
    }
?>

Alternately you use this return statement:
            return $prepend_text.l($next_node_text, 'node/'.$next_node_nid, array('title'=>'Go to the next post "'.$next_node_text.'"', 'class'=>'goto-next-node')).$append_text;

I used the above code in my node.tpl.php just below the node body like this:

<?php
   
if($page!=0)
    {
       
$previous_node_link = previous_node($node, NULL, '&lt;&lt; ', NULL);
       
$next_node_link = next_node($node, NULL, NULL, ' &gt;&gt;');   
       
        print
'<div>';
        if(
$previous_node_link && $next_node_link)
        {
            print
$previous_node_link.' | '.$next_node_link;
        }
        else if(
$previous_node_link)
        {
            print
$previous_node_link;
        }
        else if(
$next_node_link)
        {
            print
$next_node_link;
        }
        print
'</div>';
    }
?>

update:

The above functions, though functional are huge resource hogs. Doing a node_load on every node until you find the correct taxonomy term has a huge performace impact. This can be overcome by with some simple sql joins. Here is an updated function. I've also combined the 2 functions into one.

<?php
function node_sibling($dir = 'next', $node, $next_node_text=NULL, $prepend_text=NULL, $append_text=NULL, $tid = FALSE){
  if(
$tid){
   
$query = 'SELECT n.nid, n.title FROM {node} n INNER JOIN {term_node} tn ON n.nid=tn.nid WHERE '
          
. 'n.nid ' . ($dir == 'previous' ? '<' : '>') . ' %d AND n.type = "%s" AND n.status=1 '
          
. 'AND tn.tid = %d ORDER BY n.nid ' . ($dir == 'previous' ? 'DESC' : 'ASC');
   
$result = db_query($query, $node->nid, $node->type, $tid);
  }else{
   
$query = 'SELECT n.nid, n.title FROM {node} n WHERE '
          
. 'n.nid ' . ($dir == 'previous' ? '<' : '>') . ' %d AND n.type = "%s" AND n.status=1 '
          
. 'ORDER BY n.nid ' . ($dir == 'previous' ? 'DESC' : 'ASC');
   
$result = db_query($query, $node->nid, $node->type);
  }
  if(
$row = db_fetch_object($result)){
   
$text = $next_node_text ? $next_node_text : $row->title;
    return
$prepend_text . l($text, 'node/'.$row->nid, array('rel' => $dir)) . $append_text;
  }else{
    return
NULL;
  }
}
?>

(c)

Далее