Created
May 14, 2015 08:55
-
-
Save Michael-Lazell/d3dd6db239c556c9d295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The original content.getPath() | |
/** | |
* Returns the path to the content location. If the key to a content is passed, it will be used. If contenKey is null, the path | |
* to the page that the part is on will be returned. | |
* @param {Content} contentKey - content key. Example: config['saveFolder'] | |
* @return {String} Returns the path of the save location. | |
*/ | |
exports.content.getPath = function (contentKey) { | |
var defaultContent = execute('portal.getContent'); | |
var contentPath; | |
if (contentKey) { | |
var content = exports.content.get(contentKey); | |
if (content) { | |
contentPath = content._path; | |
} | |
} | |
return contentPath ? contentPath : defaultContent._path; | |
}; | |
// New version of content.getPath(); | |
/** | |
* Pass in a content id and the path is returned. If the id is null or the content does not exist, the path to the page | |
* that the part is on will be returned unless noDefault is true. | |
* @param {Content} id - Example: content._id | |
* @param {Boolean} noDefault - Force null return if no content found with the id | |
* @return {String} Returns the path of the content. | |
*/ | |
exports.content.getPath = function(id, noDefault) { | |
var content; | |
if(id) { | |
content = exports.content.get(id); | |
} | |
if (!content && noDefault) { | |
return null; | |
} else if(!content) { | |
content = execute('portal.getContent'); | |
} | |
return content ? content._path : null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment