Drupal
How to add a term name to body class
Put these codes in template.php function taxonomy_node_get_terms($node, $key = ‘tid’) { static $terms; if (!isset($terms[$node->vid][$key])) { $query = db_select(’taxonomy_index’, ‘r’); $t_alias = $query->join(’taxonomy_term_data’, ‘t’, ‘r.tid = t.tid’); $v_alias = $query->join(’taxonomy_vocabulary’, ‘v’, ‘t.vid = v.vid’); $query->fields( $t_alias ); $query->condition("r.nid", $node->nid); $result = $query->execute(); $terms[$node->vid][$key] = array(); foreach ($result as $term) { $terms[$node->vid][$key][$term->$key] = $term; } } return $terms[$node->vid][$key]; }function taxonomy_node_get_terms($node, $key = ‘tid’) { static $terms; if (!isset($terms[$node->vid][$key])) { $query = db_select(‘taxonomy_index’, ‘r’); $t_alias = $query->join(‘taxonomy_term_data’, ‘t’, ‘r.tid = t.tid’); $v_alias = $query->join(‘taxonomy_vocabulary’, ‘v’, ‘t.vid = v.vid’); $query->fields( $t_alias ); $query->condition("r.nid", $node->nid); $result = $query->execute(); $terms[$node->vid][$key] = array(); foreach ($result as $term) { $terms[$node->vid][$key][$term->$key] = $term; } } return $terms[$node->vid][$key]; […]
Posted in Drupal | Comments Off on How to add a term name to body class
Services Single Sign-On Drupal
A.Setting up the SSO Server site. 1.Install Services 3.x and enable the main Services module plus the REST server. 2.Install Services single sign-on server helper 3.Set up an endpoint in Structure > Services with the following settings: Server: REST, Authentication: Session authentication 4.Under the “server” tab of the endpoint, make sure response formatters: json and request parsing: application/json application/x-www-form-urlencoded are checked. 5.Under the “resources” tab of the endpoint, enable user.retrieve, user.index, user.login and user.logout B.Setting up your SSO Client site. 1.SSO Client site. 2.Install the Services single sign-on client module 3.Under Configuration > Web services > Services single sign-on client settings, fill in the server address of the SSO […]
Posted in Drupal | Comments Off on Services Single Sign-On Drupal
The clean URL test failed.
-Check mod_rewrite in httpd.conf -In .htaccess-Check mod_rewrite in httpd.conf -In .htaccess <Directory /var/www/drupal> AllowOverride All </Directory> AccessFileName .htaccess restart
Posted in Drupal | Comments Off on The clean URL test failed.
user_relationships in node.tpl.php
<?php $uid = $node->uid; $owner = $node->name; //if users are friends and relationship has been approved if ($relationships = user_relationships_load( array(’between’ => array($user->uid, $uid),’approved’ => 1))) { // set a value of friends to 1 to allow content to be displayed below. $friends = 1; } else { $friends = 0; } echo "friends value = " . $friends; ?> <div class="content clear-block"> <?php if ($friends == 0) { print render($content); }; ?> </div><?php $uid = $node->uid; $owner = $node->name; //if users are friends and relationship has been approved if ($relationships = user_relationships_load( array(‘between’ => array($user->uid, $uid),’approved’ => 1))) { // set a value of friends to 1 to allow […]
Posted in Drupal | Comments Off on user_relationships in node.tpl.php
Drupal node uid Reset
alter table node auto_increment=0;
Posted in Drupal | Comments Off on Drupal node uid Reset
For How to rebuild node_comment_statistics on Drupal 7
TRUNCATE TABLE at3_node_comment_statistics; INSERT INTO at3_node_comment_statistics ( nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count ) SELECT n.nid, IFNULL(last_comment.created,n.changed) AS last_comment_timestamp, IFNULL(last_comment.name,null) AS last_comment_name, IFNULL(last_comment.uid,n.uid) AS last_comment_uid, IFNULL(comment_count.comment_count,0) AS comment_count FROM at3_node AS n LEFT OUTER JOIN (SELECT nid, COUNT(*) AS comment_count FROM at3_comment WHERE status=1 GROUP BY nid) AS comment_count ON comment_count.nid=n.nid LEFT OUTER JOIN (SELECT nid, MAX(cid) AS max_cid FROM at3_comment WHERE status=1 GROUP by nid) AS max_node_comment ON max_node_comment.nid=n.nid LEFT OUTER JOIN (SELECT cid,uid,name,created FROM at3_comment ORDER BY cid DESC LIMIT 1) AS last_comment ON last_comment.cid=max_node_comment.max_cid WHERE n.status=1 ORDER BY n.nid;TRUNCATE TABLE at3_node_comment_statistics; INSERT INTO at3_node_comment_statistics ( nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count ) SELECT n.nid, IFNULL(last_comment.created,n.changed) AS last_comment_timestamp, IFNULL(last_comment.name,null) AS […]
Posted in Drupal | Comments Off on For How to rebuild node_comment_statistics on Drupal 7