Jump to content

Which should go first


Mr_CHISOL

Recommended Posts

This isn't really a PHP question (though I'm using PHP for this), but all you here are programmers, so you should have some idea...I'm working with a component to display qoutes (The problem is the same with images) and the user can choose when a quote should be displayed.The user can choose the exact date, but also if some of the part (or whole) should be random/any. Ex: They can choose that the quote only should be displayed in december or the 21:st in each month (The user can also choose week)The user can also create categories to "sort" the quotes in, which have the same properties as the quotes. The user can for example create a category whith only "christmas quotes" and show them in december.Hope you get it, but it gets more complex, an here's the question:If the user sets one date/week on the quote and another on the category there's a problem with contradictions on when the quote should be shown.How should I solve this, which should "go first"; category or quote.I would really appreciate any ideas on how You would do this.

Link to comment
Share on other sites

You could check if a quote is already set for that date, or random and if it is send them back a page with an alert saying that there is already a quote for that date? Or, if you want a few randoms on one day check if it is also set as random.

Link to comment
Share on other sites

I think which one takes precedent is up to you. I would suggest, however, that since the quotes are at the most atomic level (i.e. a quote can belong to one or more categories but a category cannot belong to a quote), any settings specific for a quote should take precedent over settings specific for a category.reportingsjr's suggestion is good because it would prevent any conflict between multiple settings.

Link to comment
Share on other sites

To reportingsjr:No, I think you misunderstood.The user can set a date like 0-21-0 (where 0 means random/any) on both quotes and categories.When I'm dislpaying a quote I take them from a database with and if I get more than one back I'll choose one by random.I'm pretty shure on how the query should look like, but my problem is if I should treat the dates asigned to the categories as ranked higher than the quotes.the SQL is going to look something like this

SELECT * FROM kacquotes WHERE published = 1 AND ( ... )

Ok, I know it in my head, just to tired to write it out at the moment, maybe tomorrow.jesh:I think you're right, but I just twist it up in my head right now... :?)Bear with me, but: If a quote are set to be displayed in april and belongs to category that are set to december shouldn't I still display that quote in december, or should I ignore it.

Link to comment
Share on other sites

I think giving example quotes and examples of possible user settings to be anticipated would be best in making us understand what exactly you have problem with. I mean, with your last post, I don't see a problem- if there's a conflict, choose at random. It is a great solution really.And I do agree with jesh too. Selecting things by specificity is always best.

Link to comment
Share on other sites

It seems like a non-issue. Since quotes are "disabled" by default (they won't display on any day unless you tell them to), this seems like an OR condition. If the date on the quote, or the date on any category that the quote is in, is today, then the quote is a contender to be displayed. It would work differently if you were choosing dates not to show a quote on, but since you're choosing dates to show quotes on, it seems like you would show a quote if it met any of the date criteria, even if one of the criteria did not match.

Link to comment
Share on other sites

It seems like a non-issue. Since quotes are "disabled" by default (they won't display on any day unless you tell them to),..
They will... If a quote doesn't have a specific year, they can be shown any year, if they don't have specific month, they can be show any month and if they don't have specific day, they can be shown any day...
Link to comment
Share on other sites

Why not make it so more than one quote can be displayed?
I just wanna display one quote on the first page, no more, no less.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...