Writing location data in Drupal

I have some code that creates a new node in Drupal, but I want to write some data in the Location field. How should I do it? Can I use the $ node object?

+1


source to share


2 answers


Is the location field a new field that you want to add to your custom nodes?

You will have to handle a couple of hooks. insert , update , delete , load , form , view .

So, you need to add a field to your table. Display the field on the form. Save it when inserting a new node. Update node while editing node. Load the field back to node. Remove the line when deleting node. And display the field when viewing node (teaser or full). node link .



At the bottom of each of these hook pages, an example is shown using {mytable} and a field named "extra".

[edit] additional information.

The module adds $ node -> and $ node -> locations fields. Therefore, I think to answer your question. Yes. You can change them through the $ node object.

+1


source


$ node -> location -> {field_name} if node has one location, or $ node -> locations [{num}] -> {field_name} should work.



0


source







All Articles