Перейти к содержимому


Фотография
- - - - -

Delete the reference to the primary category


Лучший Ответ SmetDenis , 18 March 2014 - 08:43

Hello, Adrian

As I see, you used Itemcategory element.

Please, open file \media\zoo\elements\itemcategory\itemcategory.php
and find function render()

Replace it to this code

    public function render($params = array())
    {
        $params = $this->app->data->create($params);
        $values = array();

        $primaryCategory = $this->getItem()->getPrimaryCategoryId();

        foreach ($this->_item->getRelatedCategories(true) as $category) {

            if ($primaryCategory != $category->id) {
                $values[] = $params->get('linked') ? '<a href="' . $this->app->route->category($category) . '">' . $category->name . '</a>' : $category->name;
            }
        }

        return $this->app->element->applySeparators($params->get('separated_by'), $values);
    }
tm1_200x0.png

After that, element will output only additional categories (not primary).

Best regards. Перейти к сообщению


  • Закрытая тема Тема закрыта
Сообщений в теме: 5

#1 Adrian

Adrian

Отправлено 17 March 2014 - 19:33

I have a related question.

In my site I can see the subcategories.

but .. how could I remove the primary category?

Let me explain it further.

I have database with an inventory of a few hundred plants and animals (flora and fauna) in a certain area.

I am using the JBZoo catalog database template.

See http://gorsselseheid...=214&Itemid=158

In the first column you see the primary category ("vogels", birds) separated bij a "pipe" from the subcategory ("zangvogels", "reigers" etc).

I want to omit the primary category in the table because that is already visible in the title but I cannot find how to do that.

I have used firefox firebug to find out where I can modify the relevant php file(s) to delete the reference to the primary category but I cannot find it.

Is there someone who could give me a hint?

thanks in advance

Adrian


  • 0

#2 SmetDenis

SmetDenis

Отправлено 18 March 2014 - 08:43   Лучший Ответ

Hello, Adrian

As I see, you used Itemcategory element.

Please, open file \media\zoo\elements\itemcategory\itemcategory.php
and find function render()

Replace it to this code
    public function render($params = array())
    {
        $params = $this->app->data->create($params);
        $values = array();

        $primaryCategory = $this->getItem()->getPrimaryCategoryId();

        foreach ($this->_item->getRelatedCategories(true) as $category) {

            if ($primaryCategory != $category->id) {
                $values[] = $params->get('linked') ? '<a href="' . $this->app->route->category($category) . '">' . $category->name . '</a>' : $category->name;
            }
        }

        return $this->app->element->applySeparators($params->get('separated_by'), $values);
    }
tm1_200x0.png

After that, element will output only additional categories (not primary).

Best regards.
  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#3 Adrian

Adrian

Отправлено 18 March 2014 - 11:05

Thanks SmetDenis.

It works !

Super

I am very happy with your rapid answer because I had spent many hours and could not find an answer.

Perhaps would it be be a good idea to incorporate a new element 'item-subcategory' when updating JBzoo ? Or to give an option in the global config section to omit the primary category from the table.

Best wishes

Adrian 

(the Netherlands)


  • 0

#4 SmetDenis

SmetDenis

Отправлено 18 March 2014 - 11:13

Hello,

For safe updating Zoo, copy file
media\zoo\elements\itemcategory\itemcategory.php
to
\media\zoo\applications\jbuniversal\elements\itemcategory\itemcategory.php

So, new file reload original and you can be calm.

Bets regards.
  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#5 Adrian

Adrian

Отправлено 19 March 2014 - 10:38

thank you very much for your advice. I will certainly do so to prevent overwriting when updating ZOO.

As an alternative is it possible to put the revised code (as in #3) in the custom.css file?

Regards

Adrian


  • 0

#6 SmetDenis

SmetDenis

Отправлено 20 March 2014 - 10:08

Hello, Adrian,

 

As an alternative is it possible to put the revised code (as in #3) in the custom.css file?
 

 

For CSS styles, I recommend you overload it in your own *.css files - just use the same selectors.

 

Best regards


  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.





Click to return to top of page in style!