本文整理汇总了PHP中AkrecipesFrontendHelper::getCategoryNameByCategoryId方法的典型用法代码示例。如果您正苦于以下问题:PHP AkrecipesFrontendHelper::getCategoryNameByCategoryId方法的具体用法?PHP AkrecipesFrontendHelper::getCategoryNameByCategoryId怎么用?PHP AkrecipesFrontendHelper::getCategoryNameByCategoryId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AkrecipesFrontendHelper
的用法示例。
在下文中一共展示了AkrecipesFrontendHelper::getCategoryNameByCategoryId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getItems
/**
* Method to get an array of data items
*
* @return mixed An array of data on success, false on failure.
*/
public function getItems()
{
$items = parent::getItems();
//error_log("In AkrecipesModelRecipesbyuser::getItems Count == " . count($items) ) ;
foreach ($items as $item) {
//get the tags
$item->tags = new JHelperTags();
//$item->tags->getItemTags('com_akrecipes.recipe',$item->id);
$item->tags->getItemTags($item->type_alias, $item->id);
if (isset($item->catid)) {
// Get the title of that particular template
$title = AkrecipesFrontendHelper::getCategoryNameByCategoryId($item->catid);
// Finally replace the data object with proper information
$item->catid = !empty($title) ? $title : $item->catid;
}
if (isset($item->cuisines_id) && $item->cuisines_id != '') {
if (is_object($item->cuisines_id)) {
$item->cuisines_id = ArrayHelper::fromObject($item->cuisines_id);
}
$values = is_array($item->cuisines_id) ? $item->cuisines_id : explode(',', $item->cuisines_id);
$textValue = array();
foreach ($values as $value) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('name'))->from('`#__akrecipes_cuisines`')->where($db->quoteName('id') . ' = ' . $db->quote($db->escape($value)));
$db->setQuery($query);
$results = $db->loadObject();
if ($results) {
$textValue[] = $results->name;
}
}
$item->cuisines_id = !empty($textValue) ? implode(', ', $textValue) : $item->cuisines_id;
}
// set meal_course values
if (isset($item->meal_course_id) && $item->meal_course_id != '') {
if (is_object($item->meal_course_id)) {
$item->meal_course_id = ArrayHelper::fromObject($item->meal_course_id);
}
$values = is_array($item->meal_course_id) ? $item->meal_course_id : explode(',', $item->meal_course_id);
$textValue = array();
foreach ($values as $value) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('name'))->from('`#__akrecipes_meal_course`')->where($db->quoteName('id') . ' = ' . $db->quote($db->escape($value)));
$db->setQuery($query);
$results = $db->loadObject();
if ($results) {
$textValue[] = $results->name;
}
}
$item->meal_course_id = !empty($textValue) ? implode(', ', $textValue) : $item->meal_course_id;
}
// set brand values
if (isset($item->brand_id) && $item->brand_id != '') {
if (is_object($item->brand_id)) {
$item->brand_id = ArrayHelper::fromObject($item->brand_id);
}
$values = is_array($item->brand_id) ? $item->brand_id : explode(',', $item->brand_id);
$textValue = array();
foreach ($values as $value) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('brand_name'))->from('`#__akrecipes_brands`')->where($db->quoteName('id') . ' = ' . $db->quote($db->escape($value)));
$db->setQuery($query);
$results = $db->loadObject();
if ($results) {
$textValue[] = $results->brand_name;
}
}
$item->brand_id = !empty($textValue) ? implode(', ', $textValue) : $item->brand_id;
}
}
return $items;
}
示例2: getItems
/**
* Method to get an array of data items
*
* @return mixed An array of data on success, false on failure.
*/
public function getItems()
{
$items = parent::getItems();
foreach ($items as $item) {
if (isset($item->tags)) {
// Catch the item tags (string with ',' coma glue)
$tags = explode(",", $item->tags);
$db = JFactory::getDbo();
// Cleaning and initalization of named tags array
$namedTags = array();
// Get the tag names of each tag id
foreach ($tags as $tag) {
$query = $db->getQuery(true);
$query->select("title");
$query->from('`#__tags`');
$query->where("id=" . intval($tag));
$db->setQuery($query);
$row = $db->loadObjectList();
// Read the row and get the tag name (title)
if (!is_null($row)) {
foreach ($row as $value) {
if ($value && isset($value->title)) {
$namedTags[] = trim($value->title);
}
}
}
}
// Finally replace the data object with proper information
$item->tags = !empty($namedTags) ? implode(', ', $namedTags) : $item->tags;
}
if (isset($item->catid)) {
// Get the title of that particular template
$title = AkrecipesFrontendHelper::getCategoryNameByCategoryId($item->catid);
// Finally replace the data object with proper information
$item->catid = !empty($title) ? $title : $item->catid;
}
if (isset($item->cuisines_id) && $item->cuisines_id != '') {
if (is_object($item->cuisines_id)) {
$item->cuisines_id = ArrayHelper::fromObject($item->cuisines_id);
}
$values = is_array($item->cuisines_id) ? $item->cuisines_id : explode(',', $item->cuisines_id);
$textValue = array();
foreach ($values as $value) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('name'))->from('`#__akrecipes_cuisines`')->where($db->quoteName('id') . ' = ' . $db->quote($db->escape($value)));
$db->setQuery($query);
$results = $db->loadObject();
if ($results) {
$textValue[] = $results->name;
}
}
$item->cuisines_id = !empty($textValue) ? implode(', ', $textValue) : $item->cuisines_id;
}
if (isset($item->meal_course_id) && $item->meal_course_id != '') {
if (is_object($item->meal_course_id)) {
$item->meal_course_id = ArrayHelper::fromObject($item->meal_course_id);
}
$values = is_array($item->meal_course_id) ? $item->meal_course_id : explode(',', $item->meal_course_id);
$textValue = array();
foreach ($values as $value) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('name'))->from('`#__akrecipes_meal_course`')->where($db->quoteName('id') . ' = ' . $db->quote($db->escape($value)));
$db->setQuery($query);
$results = $db->loadObject();
if ($results) {
$textValue[] = $results->name;
}
}
$item->meal_course_id = !empty($textValue) ? implode(', ', $textValue) : $item->meal_course_id;
}
}
return $items;
}