Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Sorting Functions

Options
  • 26-10-2010 7:04pm
    #1
    Registered Users Posts: 123 ✭✭


    How do you create links for sorting content on a website. I mean things like sort by: latest, most popular etc.?

    I've been googling away, but to no avail. It's probably just a matter of knowing the correct terminology for what I'm looking for. I'm in week 2 of a FAS web design course so excuse my ignorance!


Comments

  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    ballyrhy86 wrote: »
    How do you create links for sorting content on a website. I mean things like sort by: latest, most popular etc.?

    I've been googling away, but to no avail. It's probably just a matter of knowing the correct terminology for what I'm looking for. I'm in week 2 of a FAS web design course so excuse my ignorance!

    Is all that information already on the page ?

    There are two ways of doing it.

    1) In the query to the database, server-side....e.g. for PHP it's "ORDER BY DATE DESC" if you want newest first

    2) Client side using something like jQuery's tablesorter plugin


  • Registered Users Posts: 4,081 ✭✭✭sheesh


    ballyrhy86 wrote: »
    How do you create links for sorting content on a website. I mean things like sort by: latest, most popular etc.?

    I've been googling away, but to no avail. It's probably just a matter of knowing the correct terminology for what I'm looking for. I'm in week 2 of a FAS web design course so excuse my ignorance!

    you could use jquery but an explanation might be complicated

    the most straightforward way would be to have different pages for each sorting option.

    so you have a list of articles these atricles have a date, a popularity rating, a title and a topic

    the user selects a to order them by date in drop down list

    you then create a new page with a scripting language ordering the output by the date which is reasonably easy...

    So this list you have... where is the data coming from.


  • Registered Users Posts: 123 ✭✭ballyrhy86


    sheesh wrote: »
    you could use jquery but an explanation might be complicated

    the most straightforward way would be to have different pages for each sorting option.

    so you have a list of articles these atricles have a date, a popularity rating, a title and a topic

    the user selects a to order them by date in drop down list

    you then create a new page with a scripting language ordering the output by the date which is reasonably easy...

    So this list you have... where is the data coming from.

    Okay I see. The data will be coming from submissions from users. I'm thinking they'll then be able to vote on other content simply by clicking on a button under the submissions. I want people to be able to sort by the results of the votes if you get me!?


  • Registered Users Posts: 4,081 ✭✭✭sheesh


    ballyrhy86 wrote: »
    Okay I see. The data will be coming from submissions from users. I'm thinking they'll then be able to vote on other content simply by clicking on a button under the submissions. I want people to be able to sort by the results of the votes if you get me!?

    so a user votes for something. these votes have to be stored somewhere. so you will need a database and a scripting language like php or asp.

    the database has a table that has a list of the links and the number of votes for each link when the list of links needs to be displayed you would create an sql query.
    so the table name might be 'link-votes'
    the table might have columns called 'links' and another column called 'votes'
    Links would hold a string and contain the text of the link
    votes would hold an integer and store the number of votes

    you create an sql query to search the table to get the names of the links and the number of votes for each link then order the data by the number of votes (sounds complicated but it is easy)

    then you would take this query and use php or asp to get the data out of the database and convert it to html and display it in a browser.


    you would also need more php or asp to enter the votes into the database when a user entered a vote.


    It sounds alot more complicated than it is especially if you have a simple table structure.

    but if you have not done it before it can be confusing.


  • Registered Users Posts: 123 ✭✭ballyrhy86


    That makes sense to me, sounds like exactly what I want, I just have no idea about php or sql! I'll learn!

    What I have at the moment is separate pages for latest, most popular and so on. These pages are exactly the same except for an iframe with a different source. This source is a page corresponding to whether you click on latest or most popular or whatever.

    Does that make sense?

    Would I then be right in saying that I need a php to count the votes on each submission, I need a database to hold the submissions and the votes, I need a sql query to sort the submissions based on the votes and I then need another php to convert this sorted content into html and push it back into the iframe!?


  • Advertisement
  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    Why are you using an iframe ?

    If this is a public page then using an iframe is a bad idea.


  • Registered Users Posts: 123 ✭✭ballyrhy86


    Liam Byrne wrote: »
    Why are you using an iframe ?

    If this is a public page then using an iframe is a bad idea.

    Why is that? Sorry I'm very much a beginner!

    I want to have an area of the page which is consistent throughout the website but holds varied content from page to page. I happened across the iframe tag when I was trying to achieve this and thought it would be ideal!

    What alternative should I use to achieve this?


  • Closed Accounts Posts: 18,163 ✭✭✭✭Liam Byrne


    ballyrhy86 wrote: »
    Why is that? Sorry I'm very much a beginner!

    If Google directs someone to the content page, the "consistent" content (navigation, etc) won't be on that page.

    So someone finds the page for "the product that I really, really want to contact the company about" and has no "contact us" link to click.

    There are also problems with accessibility, navigation (back buttons vary as to how they deal with them), bookmarking and SEO
    ballyrhy86 wrote: »
    What alternative should I use to achieve this?

    Either Dreamweaver-style templates or server-side include files.


  • Registered Users Posts: 123 ✭✭ballyrhy86


    Liam Byrne wrote: »
    If Google directs someone to the content page, the "consistent" content (navigation, etc) won't be on that page.

    So someone finds the page for "the product that I really, really want to contact the company about" and has no "contact us" link to click.

    There are also problems with accessibility, navigation (back buttons vary as to how they deal with them), bookmarking and SEO

    Either Dreamweaver-style templates or server-side include files.

    Yeah I get what you mean, it'd be very messy having a page within a page alright. I haven't a notion about any of the server side stuff though, I think I'll try to take it as far as I can design wise then bring in the pros!

    I might just use iframe for design purposes until I learn something more suitable or I get someone on board to finish the site.


Advertisement