Jump to content

Need Some Quick Help!


Sintax
 Share

This topic is 6516 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I am trying to finish up my first project for a deadline and am stuck on one part... I hope this is possible.

I need to display a "product rating" for each record. I want the output for the data to be a graphic ( 1 - 5 stars for example). How can I have the user do this?

My idea was to present a set of Radio Buttons which they could choose one of the five options. Now how would I get their rating to display as a certain graphic in a Layout / Template?

Anyone on tonight... I could sure use the help!

Thanks

Version: v7.x

Platform: Mac OS X Panther

Link to comment
Share on other sites

Make five different graphics, store them in a five fields. Then make a calculated container field and use the Case or Choose function to return the correct image based on the rating.

Link to comment
Share on other sites

So I need to make five new fields... are they text fields?

I am sorry but I am new to FileMaker. The fact that this is possible gives me hope but would you mind take a couple minutes and walk me through it... it would really be great if you could!

Many thanks

Link to comment
Share on other sites

Make five container fields, then paste the images in. Then make the calculation field (set result to container)

Case (

Rating = 1, Rating1Star,

Rating = 2, Rating2Star,

Rating = 3, Rating3Star,

Rating = 4, Rating4Star,

Rating = 5, Rating5Star

)

Link to comment
Share on other sites

OK, I think I got that all done. When you say "paste the images in", you mean I need to create a new Layout / Template with those fields and drag and drop the images in?

Now how do I place this on my "results" page so it displays the correct image?

Thanks again for the help... really appriciate it!

Link to comment
Share on other sites

OK, in an attempt to not waste your time anymore I am going to layout exactly what I have done so perhaps you can tell me where I have gone wrong.

(1) I created 6 new fields in my table:

Rating1Star (container)

Rating2Star (container)

Rating3Star (container)

Rating4Star (container)

Rating5Star (container)

MyRating (calculation)*

*Caluclation Result = Container

MyRating =

Case (

Rating = 1; Rating1Star;

Rating = 2; Rating2Star;

Rating = 3; Rating3Star;

Rating = 4; Rating4Star;

Rating = 5; Rating5Star

)

-------

(2) I went into the layout where I want the rating graphic to show up and placed the "MyRating" field there with the exact demensions of the image.

(3) I went into an emtpy layout and created the "Rating1Star - Rating5Star" fields. They are currently empty as I have no idea how to get the images inside them (they just past on top). Do these need to be radio buttons some how or how does the user select which rating they want to give?

Link to comment
Share on other sites

Well a drop down list would be my ideal situation for selecting a rating since it takes up less space.

I just can't seem to get it to work. As I said, I am new to FM but haven't come into any problems until this. Guess it is the whole calculation field stuff... I must be doing something wrong.

I guess the record has to have a review assigned to it before the image will display... that would make sense. Now I am confusing myself frown.gif

Link to comment
Share on other sites

Do I need another field called "Rating" to capture the data? Perhaps that may be the problem. "Rating" was being used by another value so I called it "MyRating"... would that matter using your example above?

Link to comment
Share on other sites

Here a quick example

Five container fields with (very crude, sorry, my photoshop skills are as yet undeveloped laugh.gif) graphics, set to be global

One calculation field, set to to have a container as a result.

One text field with popup menu, to make a choice between ratings

And one text field that would hold the product name

The five containers were all filled with the 'graphics' laugh.gif in browse mode. As those fields are global, you can even erase them afterward!!

ratingbygraphic.zip

Link to comment
Share on other sites

Note: you can de-Case Ano's ratinggraphic or Sintax's MyRating field and make them short and sweet with GetField.

ratinggraphic = GetField( "gRating" & rating )

MyRating = GetField( "Rating" & Rating & "Star" )

Link to comment
Share on other sites

smile.gif

Instead of the 'Case' calculation, you can use the calculation -Queue- posted. Works a treat, is shorter too! And suppose you'd decide at some point in the future that it would be better to work on a scale of 1 to 10, instead of 1 to 5, you simply create gRating6, gRating7, etc. and they will work immediately, without having to add anything to the calculation.

Link to comment
Share on other sites

To elaborate, GetField allows you to dynamically get the value of several fields, in this case by concatenating text with the value of another field.

GetField( "gRating" & Rating ) equals GetField( "gRating1" ) when Rating = 1, GetField( "gRating2" ) when Rating = 2, and so forth.

Link to comment
Share on other sites

I'm on my first cup of coffee, so I may be missing something here. But, iInstead of cluttering up the database with a global container field for each image, what about a single global field with, say, 10 repetitions, where each rep from 1 to 10 contains the equivalent number of stars in the image?

In this case, your calculation (container) field to display the stars would only need to be defined as:

GetRepetition ( g_ratinggraphic ; rating )

If more stars are ever required, you'd only need to add repetitions to the global container, rather than having to add more fields to the database.

Version: v7.x

Platform: Mac OS X Panther

ratingbygraphic_new.fp7.zip

Link to comment
Share on other sites

So here is my question: would I just have one "star" graphic and it would just display it the necessary number of times or could I have a different graphic for each rating?

Also, where do I store the graphics in my database so it could find them? Right now I have a Layout called "Globals" that isn't accessable from the layouts menu. In there is where my image rating graphics are.

Link to comment
Share on other sites

Sintax:

To do what Jim suggested, define a field called "Stars" and make it a global container field with five repetitions (I think you mentioned earlier you wanted from 1 to 5 stars). In your "Globals" layout, put your "Stars" field in, and make it show five repetitions.

In your image editing application, create five different images, with one to five stars in them. Paste them, in order, in your container field in the "Globals" layout. Then, create a (or use your already-existing) container field in your regular layout. If you use the calculation Jim suggested, it should pick out the correct repetition in your global field & enter it into the container field, based on the rating (from 1 to 5.)

-Stanley

Link to comment
Share on other sites

GetRepetition and GetField for use with containers like this is "6 thinking."

We now have no limit on tables. So you can use a simple relationship, no calculations required:

- make a new table "stars" that has a starContainer field and a starNumber field.

- make 5 records, numbered 1-5, put the corresponding graphic into each container

- make a relation from your rating field to the starNumber

- put starContainer on your layouts

- stop drinking so much coffee

Link to comment
Share on other sites

More "7 thinking":

Now that you can display a portal specifying the starting row, or a repeating field specifying the starting rep, you could actually get away with just one star graphic + some clever calculations.

I think my related stars table is the simplest though, and yes, you would create a different graphic for each rating.

Link to comment
Share on other sites

Fitch said:

GetRepetition and GetField for use with containers like this is "6 thinking."

<and>

"more 7 thinking"

OMG. The thought police are already on the job wink.gif -- just kidding, Fitch.

I actually thought about doing this (the dedicated table suggestion). But, in "jim thinking," this adds more complexity than is required for such a simple process ... not to mention cluttering up the Relationships GUI (for which I've already developed a healthy case of fear and loathing) with yet another table occurrence. I suppose if I were going to situate my globals, preferences and the like into a single table somewhere, I'd do exactly what you suggested.

That said, these are the sorts of things that version 7 will have us discussing and debating. So, thanks for your input on this. For now, the approach I'm taking, given all the new features, is this:

I know I CAN DO it that way, but is there a compelling reason TO DO it that way?

Sintax: if you download the file attached to my earlier post, it's all pretty clear in there how to structure the process with the two fields you'll need (repeating global container and calculated global container).

Version: v7.x

Platform: Mac OS X Panther

Link to comment
Share on other sites

"6 thinking" was a term some of the presenters at DevCon last August were using, making the point that once we start using 7, we need to reexamine some of our old ways of doing things. I only used it in that spirit -- I wasn't specifically addressing your post but this topic in general.

In this particular case, a repeating global works well. The dedicated graphics table might be easier to work with in a case where you had a lot of graphics to manage. Not exactly "compelling." But I kind of like the idea of using a separate table for graphics, and it's a way to get your feet wet with some of 7's new capabilities, that's all.

Link to comment
Share on other sites

This topic is 6516 days old. Please don't post here. Open a new topic instead.

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
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.