It might be best if keywords were the same as collections - create either creating a new on or returning the existing one.
that is how createKeyword works - either creates or returns existing. problem is that I don't always want to create a new one if not existing.
You sure? I was doing something the other week and thought it didn't.
"The new keyword object, or false if a keyword already exists with the same name and parent"
"On success, the new collection object. If a collection with this name already exists, nil or that collection object."
Well, I'm no longer sure if we are talking about the same thing.
catalog:createKeyword will do one of two things:
1. create a keyword, and return it.
2. not create a keyword, and return a pre-existing one if its already there with same name.
I think the difference in collection creation is just that you have the option to return nil vs. an existing, so you can tell whether the collection was actually created. Whereas with keywords there is no way to tell whether a new one was created or if it was already there.
I'd like to have both capabilities: to know if a new keyword was created or not (like collections), and more importantly for my present needs - the ability to know if the keyword is there without creating it if its not.
It looks like the collections API is missing this functionality as well, and I bet it would be useful there too - i.e. to test if a collection is available, without necessarily creating it if its not... Although, with collections at least there is a work-around - you could just delete it afterward if you were just checking.
I'm guessing many people who read this might ask why one would want to check for a collection or keyword if you weren't planning on creating it. In the case of collections, I can imagine writing a plugin that has the option to use a user created collection for something if available, else do things differently... In the case of keywords, one application is to keep from inadvertently creating keywords due to a typo - this is an important feature for some folks trying to keep keyword entry from straying from their keywording conventions.