Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-10 of 11 total  RSS 

Getting Results for Paged Display

We can present these blog entries a better way: as a page of formatted results with links to more
results. We can do that using Drupal’s pager. Let’s grab all of the blog entries again, only this
time we’ll display them as a paged result, with links to additional pages of results and “first and
last” links at the bottom of the page.

$sql = "SELECT * FROM {node} n WHERE type = 'blog' AND status = 1 ORDER BY
n.created DESC"
$result = pager_query(db_rewrite_sql($sql), 0, 10);
while ($data = db_fetch_object($result)) {
$node = node_load($data->nid);
print node_view($node, TRUE);
}
// Add links to remaining pages of results.
print theme('pager', NULL, 10);

[drupal] Show all nodes of current type

$result = db_query('SELECT n.nid FROM {node} n WHERE n.type = '."'node_type'".' and n.status = 1');
    $output = '';
    while ($node = db_fetch_object($result))
    {
        $output .= node_view(node_load($node->nid), true);
    }

    print $output;


Drupal: edit Content inside Backend-Theme

/* If you've configured Drupal (www.drupal.org) the way that it
uses different themes for the frontend and the backend, it still kicks
you into the frontend when you edit content.
To change this you have to edit this file:
modules/system/system.module

at the end of the function "function system_menu($may_cache)" look
for the "else" part
*/

// in line ~308
// find:
if (arg(0) == 'admin')

// repalce with:
if (arg(0) == 'admin'||
(arg(0)=='node' && arg(1)=='add') ||
(arg(0)=='user' && arg(1)!='') ||
(arg(0)=='node' && (arg(2)=='edit' || arg(2)=='localizernode'))
)

Remove primary links

// remove primary links
// in the module - page.tpl.php 
// comment the three lines as shown...
<!-- Navigation Level 1 -->
<?php #if (isset($primary_links)) : ?>
<?php #print theme('links', $primary_links, array('class' => 'nav1')) ?>
<?php #endif; ?> 1

Change the word username in the form


// user.module -  function user_login_block() change username and password words

// form.inc - function theme_form_element($element, $value)  t('!title:132

login destination

// description of your code here

// login destination module enabled
  global $user; $myid = $user->uid;
return ($user->uid == 1) ? 'admin/'.$myid : 'user/'.$myid.'/edit/Address' ;

Remove the | sign in the title

// Remove the | sign in the title
// phptemplate.engine line 189 change it to :

$head_title = array(strip_tags(drupal_get_title())); 

Remove the "request new password" link

// Remove the "request new password" link

// user.module 
// Just comment (or remove) the following line in user_login_block function:
// $items[] = l(t('Request new password'), 'user/password', array('title' => t('Request new password via e-mail.')));

Disable RSS logo in Drupal

// To disable RSS logos both in the address bar and on pages in Drupal 5.1 :

// Edit theme.inc to disable feed icons

function theme_feed_icon($url) {
//  if ($image = theme('image', 'misc/feed.png', t('Syndicate content'), t('Syndicate content'))) {
//    return '<a href="'. check_url($url) .'" class="feed-icon">'. $image. '</a>';
//  }
}

// AND also edit common.inc

function drupal_add_feed($url = NULL, $title = '') {
  static $stored_feed_links = array();

/*  if (!is_null($url)) {
    $stored_feed_links[$url] = theme('feed_icon', $url);

    drupal_add_link(array('rel' => 'alternate',
                          'type' => 'application/rss+xml',
                          'title' => $title,
                          'href' => $url));
  }*/
  return $stored_feed_links;
}



sql drupal count login

// description of your code here

SELECT u.name name, count(name) anzahl         
    FROM accesslog al, users u
    where al.uid = u.uid group by name order by anzahl 
« Newer Snippets
Older Snippets »
Showing 1-10 of 11 total  RSS