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...
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
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...
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
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.
Quote:
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...
Quote:
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...
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