Friday, April 22, 2011

Use Tab Tamer module to remove the tabs (Drupal defaults in the system) that you dont want.

for example, EDIT tab in user page.
User Editview module to change views to be editable

Futhuer more, modify or add templete.php in the theme to make the fields showed vertically:

( if you do not know about templete.php, you can refer to template.php: Overriding other theme functions):

Soure: http://drupal.org/node/581488#comment-4378324

  • override the theme_editview_node_form() function (by copying it into my template.php file, and renaming it to MYTHEME_editview_node_form()).
  • comment out or delete this line:
                $header[] = $field->label();
  • Add this line...
                $cell['data'] .= "";
    ...just before this one:
                $cell['data'] .= $value;
  • Change...
                $row[] = $cell;
    ... to
                $rows[] = array($cell);
  • Change...
                return theme('table', $header, array($row), array('class' => 'editview-row')) . $buttons;
    ... to
                return theme('table', $header, $rows, array('class' => 'editview-row')) . $buttons;
Also, in the view itself, I set the "label" of all *checkbox* fields to display as 'none', because otherwise the you get the same label before and after the checkbox. For other types of fields, I left it set to "widget label".
That was my fix, and it works well. Ideally, this theme function should be rewritten to remove the logic-work out into its own function, and leave the theme_...() function as only showing how to display the data. That would make overriding the theme function less clunky.

Tuesday, April 19, 2011

Add a link(such as add to my favorite) to make the node referenced with View

source:  http://drupal.org/node/765562#comment-2822990

my related post: http://wadmin.blogspot.com/2011/04/display-suite-module-for-customizing.html

The use of a View to restrict the list of nodes simply reduces the nodes that may be referenced. Maybe you'd want to make a list of referenceable nodes that only includes content created in the last 30 days, content promoted to the front page, or some other arbitrary properties. In your case it sounds like you wouldn't use this functionality since "feedback" nodes should be able to reference any "proof" node. This functionality doesn't have anything to do with adding links to the display of a view.
If you want to add a link to "Add feedback" to a piece of content, add the Node: NID field and then rewrite it so that it is a link "Add Feedback" with the path "node/add/feedback/[node_nid]". Assuming you've set up the feedback content type with a Node Reference URL Widget, it will pull the nid from the URL and prepopulate the field.

THAT IS:
Make Node: NID to be a link by "rewrite the output of this file" and "Output this field as a link"
Translation of the name of the content type.
Source:  http://drupal.org/node/763536

Use translation interface to translate the name of the content type. However, there is a bug in i18n. When you click content create, the content names are not translated.

Solution: with following patch.

# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: \sites\all\modules\downloaded\i18n\i18ncontent
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: i18ncontent.module
--- i18ncontent.module Base (BASE)
+++ i18ncontent.module Locally Modified (Based On LOCAL)
@@ -156,13 +156,16 @@
  */
 function i18ncontent_menu_alter(&$menu) {
   $menu['node/add']['page callback'] =  'i18ncontent_node_add_page';
-  // @TODO avoid iterating over every router path.
-  foreach ($menu as $path => $item) {
-    if (!empty($item['page callback']) && $item['page callback'] == 'node_add') {
+ //fetch valid node types
+ //we just copy the behavior in node_menu()
+ $ntypes = node_get_types('types', NULL, TRUE);
+ foreach ($ntypes as $type) {
+    $type_url_str = str_replace('_', '-', $type->type);
+  $path = 'node/add/' . $type_url_str;
+    if (!empty($menu[$path]['page callback']) && $menu[$path]['page callback'] == 'node_add') {
       $menu[$path]['page callback'] = 'i18ncontent_node_add';
-      $arg = arg(NULL, $path);
       $menu[$path]['title callback'] = 'i18nstrings_title_callback';
-      $menu[$path]['title arguments'] = array('nodetype:type:'. $arg[2] .':name', $item['title']);
+      $menu[$path]['title arguments'] = array('nodetype:type:'. $type->type .':name', $type->name);
     }
   }
 }
Drupal SEO modules
http://www.kristen.org/content/drupal-seo-modules

Monday, April 18, 2011

Use google analysis
Modules for relations of nodes and display them

Use node reference, node reference view, view attach and corresponding node reference to make related blocks beside the node.

Corresponding node reference is helpful for bidirectional relations. Note: Corresponding node reference may have problem with a translated node to a non-translated node.

Use Node reference url for users to establish referred relation between nodes.

Use display suite to adjust the desplay of them.

Sunday, April 17, 2011

Views: Using explosed filter to make a search form.

source: http://drupal.org/node/545592

If you want a separate block for the exposed filter, this should be set to Yes. If you want the filter to be in the View's Block display, make sure that the Block display's "Exposed form in block" option is set to No.
Depening on the configuration you're attempting to achieve, you might want to override your default settings.
Show nothing with empty argument

source: http://drupal.org/node/358546

Add an argument of type "Global: Null". (This argument doesn't alter any behaviour directly).
Configure the new argument to:
  • display all values if the argument is not present
  • display empty text if the argument does not validate
Now change the validator to the following PHP code (without the opening and closing PHP tags of course):
// The exposed_input array has values only when
// the exposed filters have been submitted.
if (count($view->exposed_input)) {
  return
TRUE;
}
?>
When you visit your view with any argument (e.g. mysite.com/myview/start) the validator will run, find exposed_input empty and display your view's empty text. Once you hit submit on the filter it'll run as usual.
In my case I can live with the extra argument. Hopefully you can too, or at least this'll give you something to start from.

Tuesday, March 22, 2011

How to apply random items in a view
source: http://drupal.org/node/78111
  1. create a new view in administer » views » add tab.
  2. give it a name. I called mine "Random".
  3. click the "Block" section heading to get its settings.
  4. enable "Provide block"
  5. choose a "View type". I went with "List View" so that I could choose which fields display in the block.
  6. type in a title. This will be the title of the block.
  7. type in a number for the amount of nodes you want to display in the block. You can use 1 (number one) if you like.
  8. click the "Fields" section heading to get its settings.
  9. add the fields you want. I chose just "Node: Title" since I wanted just links to the nodes, not the node text themselves. You should be able to choose whichever field has the quote in your CCK node.
  10. click the "Filters" section heading to get its settings.
  11. select "Node: Type" and click "Add Filter"
  12. choose the CCK node type(s) you want to appear in the block.
  13. select "Node: Published" and click "Add Filter". (I keep forgetting this one, but it's important, since you probably don't want to display unpublished nodes.
  14. click the "Sort criteria" section heading to get its settings.
  15. select "Random" and click "Add criteria". (In views2, simply add the Sort criteria of Global:Random)
  16. click "Save"
  17. click administer » blocks and enable the block you titled in step #6.

    Monday, March 14, 2011

    In Ubercart: remove "Click here to view your order history" if the user does not have orders.

    excerpt from : http://www.ubercart.org/forum/support/17823/hide_click_here_view_your_order_history_link_if_user_has_no_order_history


    Here's a quick & dirty patch to hide the "Click here to view your order history" section of the user page if the user has no order history to view. It leaves the Orders tab alone, so the (empty) order history is still accessible; only the misleading link is removed.
    in version 1.12.2.40 of uc_order/uc_order.module, change
    function uc_order_user($op, &$edit, &$account, $category = NULL) {
      global
    $user;
      switch (
    $op) {
        case
    'view':
          if (
    $user->uid && (($user->uid == $account->uid && user_access('view own orders')) || user_access('view all orders'))) {
           
    $account->content['orders'] = array(
             
    '#type' => 'user_profile_category',
             
    '#weight' => -5,
             
    '#title' => t('Orders'),
             
    'link' => array(
               
    '#type' => 'user_profile_item',
               
    '#value' => l(t('Click here to view your order history.'), 'user/'. $account->uid .'/orders'),
              ),
            );
          }       break;
      }
    }
    ?>




    to
    function uc_order_user($op, &$edit, &$account, $category = NULL) {
      global
    $user;
      switch (
    $op) {
        case
    'view':
          if (
    $user->uid && (($user->uid == $account->uid && user_access('view own orders')) || user_access('view all orders'))) {
           
    $result = db_fetch_object(db_query("SELECT o.order_id FROM {uc_orders} AS o WHERE o.uid = %d AND o.order_status IN ". uc_order_status_list('general', TRUE), $user->uid));
            if (!
    $result) return;
           
    $account->content['orders'] = array(
             
    '#type' => 'user_profile_category',
             
    '#weight' => -5,
             
    '#title' => t('Orders'),
             
    'link' => array(
               
    '#type' => 'user_profile_item',
               
    '#value' => l(t('Click here to view your order history.'), 'user/'. $account->uid .'/orders'),
              ),
            );
          }       break;
      }
    }
    ?>
    (The two lines involving $result are the ones that have been added.)
    Hope this helps someone besides myself!

    Friday, March 04, 2011

    Modification in drupal for making filefield works.  This info was posted in http://drupal.org/node/313539 too. Please refer it for complete info.

    Title: Compatiblity with FileField: private_upload cannot work with filefield without modification of code.
    ...

    I finally found the problem.
    It is because in Private_upload.module the hook of download. If I change "return -1" to "return", then it works perfectly for the files uploaded by CCK-filefield into the priavte area (directory). Of course, this is not a solusion since all the attached file will not have access control at all.
    With a little more code tracking, I realized that there is no information related to filefield upload in the Database, if I upload files with CCK-filefield. Therefore, with
    $result = db_query("SELECT DISTINCT(u.nid) FROM {upload} u INNER JOIN {files} f ON u.fid = f.fid ".
    "WHERE f.filepath = '%s'", $filepath);
    $result will be empty and hence all the downloading is blocked no matter who is the user (even admin).
    With this conclusion, private upload cannot work with filefield without modification of code. Since paivate file attachment is not importatn to me, to have access control for file of the filefield. My solusion right now is disable private upload and:
    1) Put an .htaccess in a private directory to give access control to Drupal.
    2) Use filefield_path to set private directory of the protected filefield so that the upload files of the protected filefield go to the private direcotry.
    If anyone thinks something wrong about the solusion, please let me know.
    hosais
    ============================
    The hock of file download() in private upload module.
    ============================
    function private_upload_file_download($file) {
    $private_dir = variable_get('private_upload_path', 'private');
    if(_private_upload_starts_with($file, $private_dir)) {
    $filepath = file_create_path($file);
    $result = db_query("SELECT DISTINCT(u.nid) FROM {upload} u INNER JOIN {files} f ON u.fid = f.fid ".
    "WHERE f.filepath = '%s'", $filepath);
    while($row = db_fetch_array($result)) {
    $node = node_load($row['nid']);
    if (node_access('view', $node)) {
    return; // Access is ok as far as we are concerned.
    }
    }
    return -1; // No nodes are granting access, so veto download. <--- CHANGE THIS to return;
    }
    }

    Monday, September 28, 2009

    Want to make your Drupal showed on mobile phone?

    Check the module mobile_tools in the following link. It would detect the source and change presentation of the web.

    http://drupal.org/project/mobile_tools

    Sunday, July 06, 2008

    Domain Access Advanced Usage

    Below is excerpt from the README in the domain access module. To set the advanced usage (means that the domain editor is not only one administrator who can edit/delete all the content if necessary. The domain editor can access the contents belong to the same domain).

    In Readme.txt

    3.3 Advanced Usage

    In the event that you wish to segregate which content certain editors can control, you should not use the normal 'edit TYPE nodes' permission provided by Drupal's core Node module.  This permisson grants the ability for a user to edit all nodes of a given type.

    In the Domain Access model, this permission is not used in favor of the provided 'edit domain nodes' permission.  This permission allows editors only to edit (and delete) nodes that belong to their subdomain.

    To enable this feature, you should grant the 'edit domain nodes' permission to some roles.  Then you should enable the 'Use access control for editors' setting under the Domain Access configuration screen.

    Sunday, June 29, 2008

    Enabling book menu

    You can provide your users a menu that helps them find their way around inside your books. You do this by enabling the book navigation block on the blocks page (administer >> blocks). (Users will see the menu only when viewing the book.).

    Refer to Book: structured document publishing.

    Thursday, June 26, 2008

    Chinese in the subject of E-mail == Cannot sent

    Some system has problem if with E-mail subject is in Chinese. For example, I installed Drupal in a hosting server in the USA. When I put Chinese in the subject in the email, the system cannot send the email.

    I got the message as following:

    Drupal have following warrning:

    warning: mail() [function.mail]: Bad parameters to mail() function, mail not sent. in /home/content/h/o/s/hosais/html/includes/mail.inc on line 197.

    Solution (Using UTF-8, base64)

    I solved the problem by changing the /includes/mail.inc by adding the following code. The idea is change the subject as

    $subject = “=?UTF-8?B?” . base64_encode($subject) . “?=”;

    Source code

    mail.inc, Line 186:

    return mail(
          $message['to'],
          //mime_header_encode($message['subject']),   <== marked this
          //“=?UTF-8?B?” . base64_encode($subject) . “?=”;
          mime_header_encode("=?UTF-8?B?".base64_encode($message['subject'])."?="),      //<== added this line
          // Note: e-mail uses CRLF for line-endings, but PHP's API requires LF.
          // They will appear correctly in the actual e-mail that is sent.
          str_replace("\r", '', $message['body']),
          // For headers, PHP's API suggests that we use CRLF normally,
          // but some MTAs incorrecly replace LF with CRLF. See #234403.
          join("\n", $mimeheaders)

    ...

    Settings of the system message for user registration

    The system message, registration notice email, for example, can be set at Administrator->User management->User settings.

    Sunday, June 15, 2008

    Add footer at Site Information

    You could add a footer at Site Information.

    Saturday, June 14, 2008

    Reason why .htaccess should be avoided

    1) performance: web server has to read every time user requests and every .htaccess files in different directories.

    2) security: the configuration is based on the .htaccess files and it may not be controlled. Basically, when you enable .thaccess, you are giving the user (the owner of the directory) this privilege to the configurations.

    Refer to Apache's Web site.

    Friday, June 13, 2008

    Wildcard domain

    Check the concept for the wildcard domain.

    Wildcard domain is needed for the domain access fuctionality in Durpal.

     

    Wildcard domain on godaddy:

    You can create as many A records that you wish but you will only be able to create 1 wildcard.
    To Add an A record for your domain:
    1. Select Manage Domains from the My Products menu.
    2. Click on the domain for which you wish to change.
    3. Click Total DNS Control and MX Records.
    4. Under the A (Host) section, click the add new a record button.
    5. Enter the new IP address into the Points To Ip Address: field and the new A record in the Host field.
    6. Click OK.