Monday, June 20, 2011

Install privatemsg for social network

  1. theme for received message (locao.css), copy background image
  2. Import Translation
  3. Translate notification mail by translation interface
  4. Setting access control

Replace core filter to htmlpurifier


  1. Install library from htmlpurifier.org
  2. Allowing Youtube and external resources
  3. Setting embeded media (x and y pixels of vedio)

Tuesday, June 14, 2011

Reference a CCK field from a different content type



Ref: http://drupal.org/node/290443 (mainly Drupal 5.x)
       http://drupal.org/node/298951 for drupal 6.x (with computed field)

Monday, June 13, 2011

Tunnng the performance of drupal

1)http://pressflow.org/


David Strauss on on 2009-12-14
Pressflow is a 100% api-compliant replacement for your standard Drupal Core. There are no database schema changes. So long as you are running a normal Drupal core and meet the other system requirements (PHP5.x, MySQL 5.x), Pressflow is a "drop in" replacement.


2) http://2bits.com/

2bits.com, Inc. is a privately owned Canada federal corporation based in Waterloo, Ontario, Canada.

Sunday, June 12, 2011

Create content continue to have the type after delete the type

Ref: http://drupal.org/node/718348

Just go to menu to delete disable the link (for example Story, after delete Story type)
Create content continue to have the type after delete the type

Ref: http://drupal.org/node/718348

Just go to menu to delete disable the link (for example Story, after delete Story type)
facebook registration disable


Remove the facebook part in the registering part by disable facebook contribute module fb.registeration.
Field Datetime Time zone setting
Ref: http://drupal.org/node/767182

  1. Site's time zone - When entering data into the field, the data entered is assumed to be in the site's time zone. When the data is saved to the database, it is converted to UTC. When retrieved from the database, the data is converted to the Site's time zone for annonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.
  2. Date's time zone - With this option enabled, the date field adds a select box to explicitly specify the time zone for the date entered. When the date is saved to the database, it is not converted & the time zone information is saved with the date. When retrieved from the database, no conversion is performed and the date is displayed exactly as entered.
  3. User's time zone - When entering data into the field, the data entered is assumed to be in the user's time zone. When the data is saved to the database, it is converted to UTC. When retrieved from the database, the data is converted to the Site's time zone for annonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.
  4. UTC - When entering data into the field, the data entered is assumed to be in UTC time zone. When the data is saved to the database, it is converted to UTC (e.g. no conversion necessary). When retrieved from the database, the data is converted to the Site's time zone for annonymous users or the User's time zone for logged in users when User-configurable time zones is enabled.
  5. No time zone conversion - The date entered is not converted when saved to the database. When retrieved from the database, the data is NOT converted and is displayed exactly as entered.

Saturday, June 11, 2011

Access control of Views

It is possible that view will show the data that is not allowed to see by setting of permission.

Using PHP validation to the argument is very normal.

The php is look like the following:


global $user;
return arg(1) == $user->uid || user_access('access user profiles');

?>

Note:
users/2/edit
arg() is system-level item (not just views), and with the following values
arg(0) = 'users'
arg(1) = '2'
arg(2) = 'edit'





global  $user;
return db_result(db_query("SELECT GROUP_CONCAT(CAST(an.nid AS CHAR) SEPARATOR ',') FROM {acl_user} au INNER JOIN {acl_node} an ON au.acl_id = an.acl_id WHERE an.grant_view = 1 AND au.uid = %d", $user->uid));


?>


** Also refer to Views to display nodes based on ACL permission.
Create like button with Facebook for Drupal module

you need to enable fb.example module

Ref: http://drupal.org/node/977076

Wednesday, May 25, 2011

Adding database content directly for a CCK content type (dynamic content)

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

 

Don't add to the db directly

A Drupal node is fairly complex, so you probably don't want to add content directly to the database. Instead, you have several options:
1) Use an existing module that can handle CCK (see http://drupal.org/project/Modules/category/64)
2) Use http://drupal.org/project/node_factory, which provides an API for programmatically creating nodes
3) Use a lower-level approach like the one described at http://acquia.com/blog/migrating-drupal-way-part-i-creating-node
The last one is the most flexible, of course.
Mark

Tuesday, May 24, 2011

Input formats no longer showing up as options in Views 2

http://drupal.org/node/418438

For me, it was "image assist"

For me, it was "image assist" - I had disabled and re-enabled at some point. Image assist options changed on re-enable so that it was appearing on all paths instead of being restricted to node and comment paths which is usually the default. Resetting to default and restricting to node and comment paths fixed the problem and input formats is restored in views.

Friday, May 13, 2011

Use Views module to create a tab in user page

In page display in a view, you can choose menu tab to menu of the page settings.
Use flag module to implement user collection such as my favorite (relationship between flag and node)

flag moduleuse flag and view combine the data. User can use flag link to add or delete the flag relationship.
 
1) In the view, you need to add the relationship to mapping the node and the flag. Need to take care of Include only flagged content setting. If checked, only user flag node would be showed.

2) Use views flag refresh module to update view when flags are selected.
Views Flag Refresh is configured entirely through the Views interface. After installing the module, additional settings will be available to the Use AJAX option in each display's Basic Settings tab.
Make table in View sortable

Source: http://www.lornajane.net/posts/2009/Sortable-Views-in-Drupal-6


Drupal already has a way to do this!

  1. Edit the view you want to add the column sorting to
  2. Under "Basic Settings", look for "Style: Table" and click on the picture of a cog next to it. (if I were a serious blogger, I'd screenshot. Never mind, eh?)
  3. Scroll down to see the table settings
  4. There is a list of the fields, and a tickbox for each labelled "sortable" - tick the boxes for any columns you want users to be able to change the sort order on
 The taxomony in the Table cannot be sortable. To solve this problem, you need to use taxomony field (content taxomony). Then set the view as following:

How to add sort for content taxonomy fields

pimousse98 - Tue, 2010-03-09 23:13
Hi Agaron,
Try the following
1. Add a relationship for your content taxonomy field (click the + in "relationships" and choose content:Size or similar)
2. Add a field in your table that is Taxonomy:Term (and not content:Size). In the Relationship: drop-down, choose "content:Size term" or something similar (whatever you called your relationship in step 1.). Set up the rest of your field as usual.
3. Click the options symbol right next to style:table in the "basic settings" section. You will see a list of fields and there should be a "sortable" checkbox next to field you just added. Check it and save.
Your field should now be sortable by clicking on the table headers.
I have not tried it with node reference but I suspect it might work as well, if you get the right combination of relationships.

How to sort by term weight not alphabetically
Source: http://drupal.org/node/272424 


Great tip in #3, thank you.
For those interested, you can extend this a little bit to sort not alphabetically, but by term weight. That'll allow you to reorder terms at admin/content/taxonomy and have the sorting respect that order. Useful for sequences like "low, medium, high".
Add the relationship, and per instructions above, add the "Taxonomy: Term" field. Also, add the "Taxonomy: Weight" field. Configure the Term field as you need it, and check "Exclude from display".
On the Weight field, check "Rewrite the output of this field", and enter the token for the term field you have above. The naming convention isn't very nice in that it's hard to tell which field is the one you need. For me they looked like "[name_1]", "[name_2]", etc.
Now the weight field is what Views is showing and doing sorting on, but thanks to the rewrite the Term field is actually displayed.




    Thursday, May 12, 2011

    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);
         }
       }
     }