×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Showing the notes list on a page - newest on top?

Showing the notes list on a page - newest on top? 10 years 9 months ago #25001

  • Laurence Brevard
  • Laurence Brevard's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
When there are multiple notes on a page, the newest is at the bottom.
How can I reverse this order so the newest is on top?

Showing the notes list on a page - newest on top? 10 years 8 months ago #25408

  • Gerlof Koopmans
  • Gerlof Koopmans's Avatar
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
Ordering of your notes can be accomplished by changing the file mod_cnotes/helper.php .
Change lines 23-25 from
$query->select('*')->from('#__cnotes_notes')
            ->where('created_by = ' . $db->quote($user->id))
            ->where('url = ' . $db->quote(self::getUrl()));
to
$query->select('*')->from('#__cnotes_notes')
            ->where('created_by = ' . $db->quote($user->id))
            ->where('url = ' . $db->quote(self::getUrl()))
            ->order('id DESC');

Only drawback: the new ordering only will be visible after a 'hard' page refresh, so not immediately after adding a new note.

Regards
Gerlof

Showing the notes list on a page - newest on top? 10 years 8 months ago #25411

  • Laurence Brevard
  • Laurence Brevard's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 2
  • Thank you received: 0
Thanks for the pointer.
I had already done the equivalent by traversing the list using array_reverse when writing the on-page notes list.
This has the same behavior as changing the query, including that a new note is not at the top until revisiting the page.
in .../modules/mod_cnotes/tmpl/default.php
...
<div class="cnotes-notes">
     <?php if (count($items)) : ?>
        <?php $items = array_reverse( $items ); ?>
        <?php foreach ($items as $item) : ?>
        <div>
            <span class="title">
                <a href="<?php echo JRoute::_('index.php?option=com_cnotes&task=note.edit&id=' . $item->id); ?>">
                    <?php echo $item->title; ?>
                </a>
            </span>
            <?php echo $item->note; ?>
        </div>
        <?php endforeach; ?>
    <?php else : ?>
        <span class="cnotes-nothing">
            <?php echo JText::_('MOD_CNOTES_NO_NOTES'); ?>
        </span>
    <?php endif; ?>
</div>
...

I have made several other changes including a bug fix on the page that writes out all your notes:
components/com_cnotes/views/notes/tmpl/default.php

On that page, I removed an extra ">" that was showing up as a list of one ">" per note and I did some better column headings.

I know this is a free module that was done in a class. Is there a way to submit changes to it?
  • Page:
  • 1
Time to create page: 0.099 seconds