Skip to: site menu |main content

Welcome to my personal site. If You have any question or suggestion please feel free to contact me from contact page.

Advertisements

Contact me to place your Ads Here..

Powered by Drupal, an open source content management system

Syndicate

Syndicate content

Custom page next previous code drupal module for node pages

PHP code or module code goes as below:

<?php
/**
*@desc provides previous node object for caller
* @param <type> $node
* @param <type> $same_type
* @return <type>
*/
function _prev_node_link($node=NULL,$same_type=FALSE){
    if(
$same_type){
       
$old_node=db_fetch_object(db_query_range("SELECT * from {node} WHERE nid<'%d' AND status=1 AND type='%s' ORDER BY nid DESC",$node->nid,$node->type,0,1));

    }else{
       
$old_node=db_fetch_object(db_query_range("SELECT * from {node} WHERE nid<'%d' AND status=1 ORDER BY nid DESC",$node->nid,0,1));
    }
    return
$old_node;
}
?>

<?php
//Custom pager Links for nodes goes here
/**
*@desc Return next closest node object data caller
* @param <type> $node
* @param <type> $same_type
* @return <type>
*/
function _next_node_link($node=NULL,$same_type=FALSE){
    if(
$same_type){
       
$old_node=db_fetch_object(db_query_range("SELECT * from {node} WHERE nid>'%d' AND status=1 AND type='%s' ORDER BY nid ASC",$node->nid,$node->type,0,1));

    }else{
       
$old_node=db_fetch_object(db_query_range("SELECT * from {node} WHERE nid>'%d' AND status=1 ORDER BY nid ASC",$node->nid,0,1));
    }
    return
$old_node;
}
?>

<?php
/**
*
*/
function inders_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL){
    if(
$op=="load"){
      
$node->pager_info['prev']=_prev_node_link($node,TRUE);
      
$node->pager_info['next']=_next_node_link($node,TRUE);
    }elseif(
$op=="view"){
    }
}
/**
*
* @param <type> $vars
*/
function inders_preprocess_node(&$vars){
   if(isset(
$vars['pager_info']['prev']))
           
$vars['inders_pager_info']['prev']=l("<<".$vars['pager_info']['prev']->title,"node/".$vars['pager_info']['prev']->nid);
   if(isset(
$vars['pager_info']['next']))
           
$vars['inders_pager_info']['next']=l($vars['pager_info']['next']->title." >>","node/".$vars['pager_info']['next']->nid);
}
/**
*
*/
?>

And you can use dummy css from here:

.inders-pager{
    clear:both;
    float:none;
    height:26px;
    padding-bottom:5px;
    padding-top:5px;
}
.inders-pager-prev{
    float:left;
    margin-right: 5px;
}
.inders-pager-next{
    float:right;
    margin-left: 5px;
    color: white;
}
.inders-pager-prev a{
    color: white;
    background-color:#8F9CBF;
    padding:3px;
}
.inders-pager-next a{
    color: white;
    background-color:#4F9F5A;
    padding:3px;
}
.clear{
        clear:both;
}

 

Hello, I am using drupal 5.x,

Hello,

I am using drupal 5.x, i want to show email field accessible to all users as at the moment it is only accessible to only administrators, on profile page. can someone help?

Regards : mobile

 
 

If you are using custom theme you can do it easily..

you may need to add just edit profile form template file.

<?php
/**
* Catch the theme_user_profile function, and redirect through the template api
*/
function phptemplate_user_profile($account, $fields = array()) {
  // Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
  // will be assigned within your template.
  /* potential need for other code to extract field info */
  return _phptemplate_callback('user_profile', array('account' => $account, 'fields' => $fields));
  }
?>

Step 2 - (Drupal 4.x and 5.x) is to create your customized user_profile.tpl.php file and upload that to your active theme folder.

If you're starting from scratch, simply open notepad.exe or a similar text editor and paste in the snippets linked below to build your custom user profile page. Save it with the user_profile.tpl.php filename and upload it to your theme folder along with the template.php file.

Once you have got started with your first user_profile.tpl.php file, you can experiment with adding in more snippets or including HTML layout controls to get a feel for the flexibility this allows.

In your user_profile.tpl.php you can print $account variables. this variable contain email and username values.

 

Back to top

Related Pictures

Tags for Custom page next previous code drupal module for node pages

Recent comments

InderSingh.com v1.2
(May 18, 2012)