IMPORTANT MESSAGE REGARDING THE FORUM

As you may already know, the JoomlaWorks Forum is powered by Kunena (the only decent forum component for Joomla).

Unfortunately, the latest update for Kunena has seemingly broken all code snippets (old and new) in the forum.

Until this message is removed, please paste any code as regular text - in other words, don't use the [code]...[/code] tags in Kunena's post editor.

Keyword

Change ordering for items of same Author

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • New Member
More
4 weeks 19 hours 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; ?>

My Stock Photo Website powered by k2 : explora.mu

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • New Member
More
3 weeks 15 hours 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.

My Stock Photo Website powered by k2 : explora.mu

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

More
2 weeks 5 days ago #179236 by Fotis
Replied by Fotis 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.

IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

  • Goble002
  • Goble002's Avatar Topic Author
  • Offline
  • New Member
More
2 weeks 4 days 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 ! ;-)

My Stock Photo Website powered by k2 : explora.mu

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


Powered by Kunena Forum