Error when add node programmatically - drupal-7

I'm new in Drupal, and I want to create a website which get all news data from my old site.
I tried to use node API to create node base on my old data. It worked but when I edit my new node, I get an error : "Alias already in use".
I tried adding simple node with title and body and get the same issue.
Please help me!!
Many thanks!

you probably have duplicates nodes. Check "Generate automatic URL alias" box in your node path settings to generate an "mynode-1" for debuging

Related

image gallery - express/mongodb/react

can someone help me with my issue? I just started learning Express.
I have an images folder structure: enter image description here.
Now I store and receive them (at front) like this enter image description here.
I would like to store them at (express server) and make a get request at 'front' : get('https:// ...... /gallery')
get a list of folders in the array format [beruta16, borov , ..... etc], then iterate the array and make a new request for each element.
I think I can to make a list with folder names in JSON format like this app.use(URL,(req,res)=>res.json(array)) and also create a list of items(1,2,3 ... jpeg) for another request and send its. But I don't know how (handled create that madness).
Another way : fs.readdir(), but I am not sure if this is the right way. And for adding a new file I must do that again.
Mb's best way for this that store all URLlinks in MongoDB, but again make handle DB
Sorry, I can't find similar information for this

Drupal 7 Content type restrictions

How to add a restriction or validation for a content type that can be add only one content.
ex - Hotel web site room listing page should have only one content. After added once that only can edit or delete.
(I am a beginner for the Drupal)
Have you checked Node Limit module? I have never used it, but seems suitable for what you want to get.
Hope it helps.

Drupal 7 alter node display

I have a content type with two image fields, banner and logo.
I am trying to implement logic which will allow one of the two to display depending on whether an editor elected to display just the banner or just the logo from radio button options.
I setup a small custom module implementing hook_node_view and tried to unset the image field from the node object but no joy. Code fragment below:
function mymodule_node_view($node, $view_mode, $langcode){
unset($node->field_main_picture[$node->language][0]);
unset($node->field_main_picture);
$node->field_main_picture = null;
}
None of those attempts worked.
I found the answer to my question.
The node object contains an array called content which is the renderable data Drupal will print to screen.
It's in that array that my unsets need to take place. I.E:
unset($node->content['field_main_picture']);
And the main picture image disappears.
I hardly suggest you to work with Devel module when you are programming like that. It allows you to display variables in your page and visualize the tree. For example, you can call dpm($node) function in your hook_node_view() to see what's in $node and how to access it.

Drupal 7 Change Content Type of Existing Node

I'm just getting started with Drupal 7 (and Drupal in general) and I have a question that the internet can't seem to answer. If one of my users creates a node using a specific content type, is there an easy way to go back and change content types for that node? I know I can do this directly in the database but I'm going to use this Drupal install on a large site and the users who will need to change a node's content type won't have access to the database. I know I can also simply recreate the node using a different content type (and then re-link everything) but this seems like more work than necessary.
There is an old drupal module called nodetype that would add the functionality that I'm looking for, but this module has been marked as obsolete and abandoned. This leads me to think that this functionality has been merged into the core or is available in a different module. Any ideas?
For those looking, this module will do it: drupal.org/project/node_convert
As mentioned by Cloudkiller, node_convert module will be able to do this job for you.
There are two ways to convert the node:
Individual node conversion: Check the "Convert" tab on the node view page to convert the current node.
Bulk node conversion: Goto "Home > Structure > Node Convert templates > Add template" and create template & then conversion node in bulk.
Hope this will help !

Drupal 7 GMAP module

I am using the gmap module for Drupal 7 along with location and node location module enabled.
I have added a simple location field in my article content type. I have enabled the location block to be shown in main content type.
Now during creation of an article when I enter location values as text fields(like countries,cities etc.) without any latitude and longitudes then the map is not displayed on the article node page.
However if i do enter some latitude longitude values(either manually) or using google map's then in the article node page the map is shown.
So anybody has any ideas about this?It should work like even if i enter a country name and state it should show me the map with the marker
Hope its not too late for the answer, probably this will be helpful to someone googling for the issue..
I faced similar problems and in the end it turned out that GeoCoding was not enabled in Location module settings for the country which I was adding entries for.
You can enable GeoCoding from Location module settings (admin/config/content/location) 'GeoCoding Options' tab.

Resources