Jump to content

Ustawienie od najwiekszei do najmniejszej oceny w widget


Go to solution Solved by Majster87,

Recommended Posts

Posted (edited)

jak ustawic w tym kodzie:

 

<h3 class="mod-widget__title">Ostatnio Oceniane Mody</h3>

{{if !empty( $comments ) }}
<ul class="mod-widget-list">
{{foreach $comments as $comment}}
<li class="mod-widget-item">
<div class="mod-widget-thumb">
{{if $comment->item()->primary_screenshot_thumb}}
<img src="{file="$comment->item()->primary_screenshot_thumb->url"}" alt="{$comment->item()->name}">
{{else}}
<img src="{resource="default_mod_thumb.png" app="core"}" alt="Brak miniatury">
{{endif}}
</div>
<div class="mod-widget-info">
<div class="mod-widget-title">
<a href="{$comment->url()}">{$comment->item()->name}</a>
</div>
<div class="mod-widget-rating">
{template="rating" group="global" location="front" app="core" params="'small', $comment->rating, \IPS\Settings::i()->reviews_rating_out_of"}
<span class="mod-widget-votes">
            {{if $comment->item()->reviews > 0}}
              {$comment->item()->reviews} {{if $comment->item()->reviews == 1}}głos{{else}}głosów{{endif}}
            {{else}}
              Brak głosów
            {{endif}}
          </span>
</div>
<div class="mod-widget-downloads">
<i class="fa fa-download"></i> {$comment->item()->downloads}
</div>
</div>
</li>
{{endforeach}}
</ul>
{{endif}}



żeby sortowało od największej do najmniejszej ocenionej a nie od ostatniej ocenionej? w ustawieniach widgetu nie ma takiej opcji a edytowany jest orginalny widget Pliki - Opinie o plikach

Edited by Majster87

logo.png.519590789bae8db2833a4ecc09316aef.png

Zostaw suba, dużo pomożesz w tworzeniu: https://www.youtube.com/channel/UC8T8FoCAhg64dNIxQfCwhEQ

Posted (edited)

dodałem cos takiego:

 

public function render()
{
// Pobierz recenzje (np. 50), bez sortowania
$all = \IPS\downloads\File\Review::getItemsWithPermission(null, null, 10);
$items = iterator_to_array($all);

// Posortuj po ratingu malejąco
usort($items, function($a, $b) {
return $b->rating <=> $a->rating;
});

// Ogranicz do 5 (lub liczby z konfiguracji)
$items = array_slice($items, 0, $this->configuration['number_to_show'] ?: 4);

// Przekaż do oryginalnego szablonu
return \IPS\Theme::i()->getTemplate('widgets', 'downloads', 'front')->downloadsReviewFeed($items, $this->configuration, $this->orientation);
}

ale nie zlicza głosów do jednego ale dzieli czyli jeden mod oceniam na 5 gwiazdek daje go jako pierwszy ocenie go znowu i dam 4 to jest jako drugi:/

 

próbowałem też tak ale tym sposobem wogole nic sie nie dzieje i pokazuje orginalnie od ostatniej ocenionej 😕

 

protected function getItems()
    {
        return \IPS\downloads\File\Review::getItemsWithPermission(
            null,
            'rating DESC',
            $this->configuration['number_to_show'] ?: 5
        );
    }

 

Edited by Majster87

logo.png.519590789bae8db2833a4ecc09316aef.png

Zostaw suba, dużo pomożesz w tworzeniu: https://www.youtube.com/channel/UC8T8FoCAhg64dNIxQfCwhEQ

Posted (edited)
2 godziny temu, michu87 napisał(a):

Zmiana sortowania musi być zrobiona w kodzie PHP widgetu; najczęściej applications/downloads/widgets/comments.php 

 

 

no widzisz, przeczytaj wyzej ze robilem sortowanie niby działa ale nie zlicza, a widget co edytuje to downloadsReviewFeed.php 

a ten co podałeś odpowiada za inny

 

i nawet go nie ma

image.png.0a6cbf79dd7414c1b4bb23e0dbc1769a.png

Edited by Majster87

logo.png.519590789bae8db2833a4ecc09316aef.png

Zostaw suba, dużo pomożesz w tworzeniu: https://www.youtube.com/channel/UC8T8FoCAhg64dNIxQfCwhEQ

Posted
10 godzin temu, Weak. napisał(a):
{{usort($comments, function($a, $b) {
	return $b->rating <=> $a->rating;
})}}
{{foreach $comments as $comment}}

A tak?

na wszystrkie sposoby to probowałem ale dostaje na stronie głównej:
 

[[Template downloads/front/widgets/downloadsReviewFeed is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]

 

logo.png.519590789bae8db2833a4ecc09316aef.png

Zostaw suba, dużo pomożesz w tworzeniu: https://www.youtube.com/channel/UC8T8FoCAhg64dNIxQfCwhEQ

Posted

zrobiłem to w php

 

public function render()
{
$all = \IPS\downloads\File\Review::getItemsWithPermission(null, null, 10);
$comments = iterator_to_array($all);
usort($comments, function($a, $b) {
return $b->rating <=> $a->rating;
});
$comments = array_slice($comments, 0, $this->configuration['number_to_show'] ?: 4);
return \IPS\Theme::i()->getTemplate('widgets', 'downloads', 'front')->downloadsReviewFeed($comments, $this->configuration, $this->orientation);
}

 

ale dalej jest efekt ze nie zliczado jednego i nie daje pół gwaizdki jak jest w temacie tylko cała i rozdziela to 😕

image.png.3d3bbeec995bcd5519e3f85af3d30d97.png

logo.png.519590789bae8db2833a4ecc09316aef.png

Zostaw suba, dużo pomożesz w tworzeniu: https://www.youtube.com/channel/UC8T8FoCAhg64dNIxQfCwhEQ

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.