Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Organizing Friend-Requests

    I could use some advice on how to structure web-pages and URL's related to Friend-Requests.

    Here are the "views" that I would like to offer a member when they are viewing their account...

    1.) Manage Incoming Friend-Requests that are New
    2.) Manage Incoming Friend-Requests that they Declined
    3.) Manage Current Friends (i.e. Friend-Requests that were Accepted)
    4.) View Outgoing Friend-Requests that the Member made to Others


    Originally I had #1, #2, and #3 coded as separate web-pages, and #4 doesn't exist.

    After reviewing my code, it looks like #1 and #2 are identical except for slightly different queries. (I suspect #4 falls into this category as well.)

    #3 is different enough to need to be its own page.


    The EASY approach would be to code 4 separate pages, and live with the duplicate code. (Which wouldn't be so bad, since I don't see things changing.)

    It would also mean a simpler URL structure like this...
    Code:
    http://local.debbie/account/new-friend-requests.php
    http://local.debbie/account/declined-friend-requests.php
    http://local.debbie/account/manage-friendships.php
    http://local.debbie/account/outbound-friend-requests.php


    The TRICKY approach would be to maybe break things up like this...
    Code:
    http://local.debbie/account/friend-requests/incoming/new
    http://local.debbie/account/friend-requests/incoming/declined
    http://local.debbie/account/manage-friendships
    http://local.debbie/account/friend-requests/outgoing/all
    But that means needing Mod_Rewrites, having to re-write #1 and #2, sanitizing query strings, etc.


    Any suggestions on what would be the best approach?!

    Thanks,


    Debbie

  • #2
    Regular Coder
    Join Date
    Sep 2010
    Posts
    331
    Thanks
    9
    Thanked 6 Times in 6 Posts
    Considering I've done something very similar I don't understand why it is necessary to have 4 separate pages other than for speed? This could all be done on one page, unless like I said you're looking for the best speed.
    The way I did it was by creating a friends table with a status field. This field could be set to 0 (unconfirmed), 1 (confirmed/accepted), or 2 (declined).

    All you would need to do is use a conditional to check for the status and output the results. You could use GET to create a new link to each category or you could use AJAX to display different results depending on what the user would like to see.
    Coding is a challenge, get used to it
    Always remember to debug
    Try the guess & check method
    Break it down into simple steps

  • #3
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by elitis View Post
    Considering I've done something very similar I don't understand why it is necessary to have 4 separate pages other than for speed? This could all be done on one page, unless like I said you're looking for the best speed.
    The way I did it was by creating a friends table with a status field. This field could be set to 0 (unconfirmed), 1 (confirmed/accepted), or 2 (declined).

    All you would need to do is use a conditional to check for the status and output the results. You could use GET to create a new link to each category or you could use AJAX to display different results depending on what the user would like to see.
    You missed the entire point of my OP...

    First, I didn't say anything about "speed" being a determining factor...

    Secondly, I didn't ask how to code Friend-Requests. (If you read, I said I already have this working...)

    The emphasis was on...

    1.) Whether it is worth the hassle to re-code what grew into separate scripts into one script which is much more complicated.

    2.) If the sample "Pretty URLs" I listed are worth the hassle as well?!


    Debbie

    P.S. I'm not using AJAX, so that isn't an option...

  • #4
    Regular Coder
    Join Date
    Sep 2010
    Posts
    331
    Thanks
    9
    Thanked 6 Times in 6 Posts
    Maybe you misunderstood some of my post as well. What I was saying was I don't understand why you had 3 separate pages (didn't notice you said the 4th didn't/doesn't exist) unless you were looking for the best page load time. Never did I say, as a fact, that you were looking for the best load time.

    And since you are talking about the "hassle" of having to re-code all of this onto one page I was giving you an example of how you could put all of this onto one page. The average user doesn't usually go to or remember specific pages on a website (i.e example.com/page/, or ?id=x). So, your "pretty URL" probably wouldn't do much good. In conclusion, your "pretty URL" wouldn't be worth the hassle in my opinion, and as for putting everything onto one page, only you can truly decide if its worth the hassle. What exactly would be your reason for doing so, if your current method works fine?
    Coding is a challenge, get used to it
    Always remember to debug
    Try the guess & check method
    Break it down into simple steps

  • #5
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,071
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by elitis View Post
    Maybe you misunderstood some of my post as well. What I was saying was I don't understand why you had 3 separate pages (didn't notice you said the 4th didn't/doesn't exist) unless you were looking for the best page load time. Never did I say, as a fact, that you were looking for the best load time.
    Because my website is evolving slowly, and sometimes what is obvious to others (e.g. "You just coded 3 pages that are almost identical?!") isn't obvious to me until it is done?!

    I created one view (i.e. "Incoming Friend-Requests"), and then later I thought, "Hey, it might be nice to see 'Declined Friend-Requests' in case I change my mind later and want to 'friend' someone?!"

    And then I thought, "Hey, it might be nice to see Friend-Requests that I made to others, and see where they are in the process of Accepting/Declining me?!"

    Then I had 3 pages.


    And since you are talking about the "hassle" of having to re-code all of this onto one page I was giving you an example of how you could put all of this onto one page. The average user doesn't usually go to or remember specific pages on a website (i.e example.com/page/, or ?id=x). So, your "pretty URL" probably wouldn't do much good.
    But I'd need a Query String to have 3 different views and use one page...


    In conclusion, your "pretty URL" wouldn't be worth the hassle in my opinion, and as for putting everything onto one page, only you can truly decide if its worth the hassle. What exactly would be your reason for doing so, if your current method works fine?
    Because if I do change my code, I have to change it in 3 places...

    I comes down to having to write one script which handles Query Strings (Pretty URL or not) and Sanitizes the Query String for security - which I don't currently need with 3 separate scripts - but is just one script.

    Or, having 3 separate scripts that are nearly identical, which are easier, and already coded, but which require more maintenance.

    There is also the issue that I do think "Pretty URLs" make a website easier to navigate and use, NOT because people remember them, but because they can READ THEM and understand what they are doing and the diffeent ways you can slice and dice...


    Debbie

  • #6
    Regular Coder
    Join Date
    Sep 2010
    Posts
    331
    Thanks
    9
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by doubledee View Post
    Because my website is evolving slowly, and sometimes what is obvious to others (e.g. "You just coded 3 pages that are almost identical?!") isn't obvious to me until it is done?!

    I created one view (i.e. "Incoming Friend-Requests"), and then later I thought, "Hey, it might be nice to see 'Declined Friend-Requests' in case I change my mind later and want to 'friend' someone?!"

    And then I thought, "Hey, it might be nice to see Friend-Requests that I made to others, and see where they are in the process of Accepting/Declining me?!"

    Then I had 3 pages.




    But I'd need a Query String to have 3 different views and use one page...




    Because if I do change my code, I have to change it in 3 places...

    I comes down to having to write one script which handles Query Strings (Pretty URL or not) and Sanitizes the Query String for security - which I don't currently need with 3 separate scripts - but is just one script.

    Or, having 3 separate scripts that are nearly identical, which are easier, and already coded, but which require more maintenance.

    There is also the issue that I do think "Pretty URLs" make a website easier to navigate and use, NOT because people remember them, but because they can READ THEM and understand what they are doing and the diffeent ways you can slice and dice...


    Debbie
    URL's should be readable and easily understandable in any case. Not just for the user's benefit but for your's as a developer as well. For example, Youtube uses a query string (i.e ?watch=x) and is still very readable for the user. As does Facebook (i.e profile.php?id=x). In fact even Coding Forums has readable URL's without using a rewrite (i.e /newreply.php?do=newreply&p=x) . Not that many people notice or really even care. My point being that if you need or want to use your "pretty URL's" for readability and easy navigation, its not entirely practical. It's a bit of an overkill, if that's what you're looking for.

    I'd say do whatever works for you, but you can always use classes. I mean, their purpose and your problem are very much identical: maintenance in one area but use in multiple.

    Depending on how many pages you have and how much code you have, including all of your code in one page can be a nightmare. A lot of the time its better to have multiple pages. Although, if much of your code is identical you should be able to condense it.

    Your best bet (and possibly only bet if you don't want client-side solutions) would be query strings. Alternatively, you could use some Javascript and CSS to create your own "popup" that would display each of your 'views'.
    Coding is a challenge, get used to it
    Always remember to debug
    Try the guess & check method
    Break it down into simple steps


  •  

    Posting Permissions

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