Jump to content

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

Recommended Posts

Posted

Hi,

I'm trying to implement a CDML query that returns the newest record that contains an image. I can't for the life of me figure out a way to skip newer records that don't contain an image and return the first one that does.

(Explanation: The database provides news articles for our website, some of which contain images. I'm trying to build thumbnail links into the home page to provide shortcuts to the latest articles/content, maximum of 4. Obviously I want to avoid records that don't give me an image to use as a thumbnail.)

Any ideas?

Cheers,

Kevin Futter

Posted

First, using FM to store the images is a waste of db functionality. You will be better advised to store the images in a folder and refer to them from the individual records to which they relate. You may be able to control the thumbs through size designations on the html (format file) page, thus one image in storage. Then again, you may not and may need two images. You certainly can link FMP records to images stored elsewhere.

There are also different approaches to the problem (whether a link or an image is in the field). One approach is to control it through the find criteria. Another is to control it through an [FMP-If] on the results page.

Bon chance.

Posted

I don't supply the images myself - staff upload them directly into the database; getting them to upload them into a server folder first and then link them to the database just isn't practical - it's confusing enough for some of them the way it is. But that wasn't the question ...

I need to sort it out in the find (hence the term 'query' in my original post - this is what most database 'finds' are called), not in the format file using FMP-If.

Since you imply that this can be done, I'd be appreciative of an explanation.

Cheers,

Kevin Futter

Posted

Not only is the use of FM to store the images a waste of db functionality, you cannot perform a search on a container field. Nor can you index or sort container fields.

You cannot use the FMP-If tag with a container field to determine if it contains an image.

You need to redesign your db to allow you to identify the records with images.

Then you will be able to either perform a complex search and sort or use the FMP-If conditional.

It is all a matter of design; db and format files.

Posted

Thanks, I was beginning to suspect changes might be needed to the database. But using references in container fields is just out of the question for us, whether it's best practise or not.

Cheers,

Kevin Futter

Posted

You can create a Calculation field like this:

is_image: If(IsEmpty(myimgfld),0,1)

Hence, the search could look like this:

/FMPro?-db=mystories.fp5&-format=listing.html&is_image=1&-sortfield=story_date&-sortorder=descending&-find

The first record returned should be the latest with an image.

Good Luck.

Garry

This topic is 7487 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
×
×
  • Create New...

Important Information

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