Different icons for different nodes in extjs - extjs

I want to show the parent child relation using the tree in extjs 4. I have table which contains three fields: node_id, parent _id, and node_type. Here node_id and parent_id representing the child parent relationship. node_type is 9 digit code for node. Based on this 9 digit code, I want to show the icon of the node in tree.
There is no problem in generating the simple three with default icons for node and leaf.
But I need help implementing the different icons for node based on that node_type 9 digit code.

It should be enough to add an appropriate css class value to iconCls field of the tree record. Or just return iconCls from server as a part of json.

Use Saki's response if you have control over the server response and don't mind mixing the model and view domains. An alternative for keeping the view separated from the model is to use the Load event of TreeStore to map your node_type code to the corresponding css class iconCls on the node instance.

Related

Drupal 7: How do I use views to display information from the current node?

I have a Drupal 7 question. I would like to display certain pieces of information from my current node using a view.
I can use views to display information from other nodes easily by setting filters and other sorting features. That's no problem. However, I want to display information from the node which is currently opened. So, for example, if I'm on a page (node: 117, title: news), I can display all the images from that page, plus captions, by creating a view.
The logic, I suppose, would be to create a view with a filter (or contextual filter) stating that the node has to equal the current node, but I don't know how to do that.
Does anyone have any advice? How do I instruct a view to display information from the node which is currently open?
Thanks!
Edit the view
Add Content: Nid in contextual filter
In contextual filter options
WHEN THE FILTER VALUE IS NOT AVAILABLE
Select "Provide default value"
Type: Content ID from URL
Now the default argument will be the nid of the current node.

Maintaing tree structure after child is deleted

I have used composite views to build tree structure using code given in following example.
http://jsfiddle.net/derickbailey/AdWjU/. Additionally my model contains index (1,1.1,1.2,1.3 etc) which I have set using some logic. Now I want to remove rows (parent and header). So when I remove any row I want to update the indexes of the remaining rows.
for ex:
1. Root
1.1 a
1.2 b
1.3 c
So if I remove 1.2 from above children, then indexes for remaining rows should be
1. Root
1.1 a
1.2 c
I tried re-rendering view by binding event like :
if (this.collection) {
this.listenTo(this.collection, "remove", this.render);
}
But it is not working as it is not maintaing the values I have entered(in textboxes of sibling rows).
Make sure you are taking input from your textboxes and updating your models accordingly. Then re-rendering won't be a problem.
If the index is a property of your models, isn't the problem that you aren't updating the models when another is removed?
The following might be a useful starting point.
this.listenTo(this.collection, 'remove', this.collection.updateIndexes.bind(this.collection));

Drupal 7: Form for node maintenance

I have a content type which will contain just one node.
I need a form for the maintenance of this node, with the following logic:
If the node exists, show a form populated with the fields content, and a "update" buttom;
If not exists, show a clear form with a "insert" buttom.
What is the Drupal correct way to do this?
Thanks for any help!
if the content type will contain one node why will drupal need to check weather the node exists?
Drupal rules http://drupal.org/project/rules coupled with the core triggers and actions modules can help you setup up system logic events

Expand a tree path by sending the internalId as parameter

Please consider the situation:
I'm using Extjs' tree.Panel to have some sort of navigation on a page.
I have a list of items in another portion of the page, whose list items have a unique id that matches the internalId of a node in the tree.
I wish to bind a click for each list item and expand the tree to the node specified by the id on the item.
I intend to use the expandPath(path) method from the tree. My question would be: how can I get the path string with just the internalId? Thank you.
Unfortunately function NodeInterface.getPath was vanished from extjs4. So there is no way to use expandPath(path). But, instead, you can use
tree.store.getNodeById('ext-record-23').bubble(function(node){node.expand()});

Different style when listing nodes and displaying a single node

I'm new at Drupal, coming from the PHP framework world, and I'm having some problems understanding the the template hierarchy in Drupal 7.
I've created a template called 'node--article.tpl.php' and can style my single article nodes. The problem is that this affects the front page as well. I want to style the node list different then when displaying single nodes. How can I do this?
/ Tobias
The front page lists nodes that are flagged to be promoted to the front page. You can flag/unflag each node in the Publishing Settings section of the node add/edit form.
Drupal provides a $promote variable that is available in the node template. So, you can use that in node--article.tpl.php when determining what content you want to output:
if($promote) {
print "<h2>".$title."</h2>";
} else {
print "<h1>".$title."</h1>";
}
If you need to get more complex in determining which nodes should be listed on the frontpage, you might want to look into the Views module: http://drupal.org/project/views.

Resources