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