A
A
Aleks_Vast2020-01-28 17:27:43
laptops
Aleks_Vast, 2020-01-28 17:27:43

How to change the output format of category parameters in Joomla component?

I am developing a component according to the articles of the standard Joomla documentation. I get a list of categories that belong to my component through a request, but I can't process data in json format from the 'params' field into a variable. How to parse a Json array into a regular view.

Below is the code for getting the list of categories:

public function getCatlist(){
        if(!isset($this->catList)){
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
            $query
                ->select(array('title, description, params'))
                ->from('#__categories')
                ->where('extension = "com_mycomponent"')
                ->where('published = "1"');
            $db->setQuery($query);
            $this->catList = $db->loadObjectList();
        }
        return $this->catList;
    }


As a result, we get the following array print_r($this->catList):
stdClass Object ( [title] => Название категории [description] => Текст описания категории [params] => {"category_layout":"","image":"images\/image1.jpg","image_alt":""} )


Here's how I can convert from json format to the usual one like title and description? How is it recommended to do this?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question