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
Related
I am trying to detect when a content-type node is updated or saved for the first time and has attached audio.
If this is the case I want to re-write the Twitter Card meta tags to turn an image card into a media card and then include a link to the relevant audio field to complete the media card and player options.
I have a rule set that detects the creation / update of a node; I can screen for nodes of the correct "type", and my rule fires appropriately, but I am failing on my rule action to re-write the meta tags.
Rules tells me that $node is available to me, so I've been trying to do:
$node->metatags[LANGUAGE_NONE]['description']['value'] = 'Some description.';
$node->metatags[LANGUAGE_NONE]['title']['value'] = 'Some title | ZZZ';
This I have followed by an "entity save" action. My rationale is to write the changes before the recursion lock kicks in and stops the rule executing.
I've been going round the houses for a day trying to solve this. Can someone please point me in the right direction?
Many thanks.
Didn't fully understand your requirement. But you can easily update your node datas using hook_node_presave (https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_presave/7.x) before node is being saved in to database.
Use hook_node_insert(https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_insert/7.x) and hook_node_update(https://api.drupal.org/api/drupal/modules%21node%21node.api.php/function/hook_node_update/7.x) if you need to do the same thing after the node is saved in to database
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.
I am in Drupal 7 and want to do some side processing, i.e. neither to affect the fields nor the themeing, on a node, before the node's page is rendered. In other words, I want to implement in a custom module an 'appropriate hook' so that I can pick-up node's info. Again the implementing function I want to be executed in .module file rather than in template.php.
Thanks
Check http://api.drupal.org/api/drupal/includes!module.inc/group/hooks/7
Probably you should have a look at hook_node_view.
Using rules it's easy to fill field values of a node after user pressed the save button. Just add a rule on before saving content event. But is it possible to have a rule to prefill a node field before edit form is shown to the user? So he has a change to corrent the default values.
This is a very late reply, but hopefully someone might find it to be of some help:
If you are creating the node using Rules, you could save it first, selecting "Force saving immediately: true". In the next step, you could set the value of the node field. You might need to save again. (also 'Force save' immediately.) And in the next step, do a 'page redirect' to the edit url.
Not sure if this is an elegant way to do it, but it might work. I had a somewhat similar requirement (not the same), and this is how I finally did that - by saving first, and then redirecting to the edit url of the saved node.
Not sure if this is something you can accomplish with rules or not, but if you go to structure->content types you can click "manage fields" and edit the default value of any field other than the title field (which you could always turn off and replace with a custom title field with a default value)
I think there are basically two ways of doing this:
1) Use Rules Forms. I don't know very much about that module, and I have had some less than perfect experiences with the module, but I'm fairly certain it could be done with the module.
2) Use Rules to create a node, populate the relevant field values, and then send the user to the edit page. One downside with this approach is that if the user decides to abort the node creation, you'll end up with a half-populated node that needs deletion in one way or another.
If you choose to go for option 2, and are comfortable with Page manager and Panels, it is probably worth checking out the Rules Panes module.
What we are trying to do in Drupal 7: create a block that can be attached to a node view or taxonomy term view. In this block, a user can add links. These links can point to contacts, documents, links to other websites or taxonomy terms.
In the back-end, a user can select a contact, document or link. The user then gets a list of all nodes where this link is used. If the link is changed, it is updated in all the nodes where it is used.
In other words, a node reference that works in both directions, for multiple nodes. Any ideas are mightily appreciated :)
Hi have you tried to use Corresponding node references module? http://drupal.org/project/cnr
You can use:
http://drupal.org/project/content_dependency
It works for both node reference & entity reference modules automatically.