SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2011
    San Diego
    1 Post(s)
    0 Thread(s)

    Sorting in Smarty

    I'm using a site that was built using Smarty. I didn't type the code myself and I'm not very familiar with it so I'm hoping someone could help me out here.

    The site has posts (confessions) and people are able to leave comments, but the comments sometimes appear out of order. I would like to have them sorted in ascending order either by their child id or by date.

    Here's what I want to fix:

    PHP Code:
    The answer might come from one of these,

    Parent ID
    PHP Code:
    Time Ago in Smarty:
    PHP Code:
    Thank you

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Augusta, Georgia, United States
    17 Post(s)
    4 Thread(s)
    Well if those comments are coming from the database you *really* should consider adding sorting to the query that generates comments. Sorting the comments in a smarty template is dirty and introduces logic that really has no place at the presentation layer. The sorting should either be done outside the smarty template or ideally within the query itself to generate the comments.
    The only code I hate more than my own is everyone else's.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts