Keyword

Change ordering for items of same Author

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 4 months ago #179197 by Goble002
Hi,

I have only 1 user for the time being. So items from same Author will always show the same (Show latest). Is there a way to change ordering to "random" in item.php ? 

<?php if($this->item->params->get('itemAuthorLatest') && empty($this->item->created_by_alias) && isset($this->authorLatestItems)): ?>
    <!-- Latest items from author -->
    <div class="itemAuthorLatest">
        <h3><?php echo JText::_('K2_LATEST_FROM'); ?> <?php echo $this->item->author->name; ?></h3>
        <ul>
            <?php foreach($this->authorLatestItems as $key=>$item): ?>
            <li class="<?php echo ($key%2) ? "odd" : "even"; ?>">
                <a href="<?php echo $item->link ?>"><?php echo $item->title; ?></a>
            </li>
            <?php endforeach; ?>
        </ul>
        <div class="clr"></div>
    </div>
    <?php endif; ?>

Please Log in or Create an account to join the conversation.

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 4 months ago #179217 by Goble002
Replied by Goble002 on topic Change ordering for items of same Author
Hi,

an update here. I bought the module from Raxo : "K2 related items" and load the module in item.php. Module set to related items by author with random ordering for items.

Please Log in or Create an account to join the conversation.

More
3 years 4 months ago #179236 by JoomlaWorks
Replied by JoomlaWorks on topic Change ordering for items of same Author
You could also fetch 100 items from that user and then use a module template override to enforce a smaller item list shown (e.g. 10) and shuffle() the items before display.

So you'd change:

<?php foreach($this->authorLatestItems as $key=>$item): ?>

to:

<?php shuffle($this->authorLatestItems); foreach($this->authorLatestItems as $key=>$item): ?>
<?php if ($key >= 10) break; ?>

...if the limit to your displayed items is for example 10.

Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 4 months ago #179239 by Goble002
Replied by Goble002 on topic Change ordering for items of same Author
Thanks Fotis,

I know that there was a way ! But too late for me, this might help others ! ;-)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum