/**
* Method to get the parent asset id for the record
*
* @param Table $table A Table object (optional) for the asset parent
* @param integer $id The id (optional) of the content.
*
* @return integer
*
* @since 1.6
*/
protected function _getAssetParentId(Table $table = null, $id = null)
{
$assetId = null;
// This is an article under a category.
if ($this->catid) {
$catId = (int) $this->catid;
// Build the query to get the asset id for the parent category.
$query = $this->_db->getQuery(true)->select($this->_db->quoteName('asset_id'))->from($this->_db->quoteName('#__categories'))->where($this->_db->quoteName('id') . ' = :catid')->bind(':catid', $catId, ParameterType::INTEGER);
// Get the asset id from the database.
$this->_db->setQuery($query);
if ($result = $this->_db->loadResult()) {
$assetId = (int) $result;
}
}
// Return the asset id.
if ($assetId) {
return $assetId;
} else {
return parent::_getAssetParentId($table, $id);
}
}