Using your personalized Search

circle-check

The following sections demonstrate how to use the SharinPix Album to perform a personalized search and display all the images present on the Contact records that are related to a particular Account record. This can be done by either using a SharinPix Canvas App or by embedding the SharinPix component inside an Iframe.

Therefore, you will need:

  1. an Apex Class Controller that will build the query and generate the token.

  2. a Visualforce Page that will embed the Canvas App or the Iframe.

Apex Class Controller

  • The implementation for the Apex Class Controller can be found below.

public class SharinPixDemoAccountContactsSearchCtrl {
    private Map<String, Object> params;
    private sharinpix.Client clientInstance = sharinpix.Client.getInstance();

    public SharinPixDemoAccountContactsSearchCtrl(ApexPages.StandardController stdCtrl) {
        Id accountId = stdCtrl.getId();
        List<Contact> contacts = [SELECT Id FROM Contact WHERE AccountId = :accountId];
        String queryStr = '';
        for (Contact contact : contacts) {
            queryStr += '"' + contact.Id + '" ';
        }

        params = new Map<String, Object> {
            'path' => '/search?search_bar=false',
            'q' => queryStr,
            'download' => true,
            'download_filename' => 'my_zip_filename',
            'download_filenames' => 'inside_the_zip-00001'
        };
    }

    public String getParameters() {
        return JSON.serialize(params);
    }

    public String getSearchUrl() {
        return clientInstance.token(params);
    }
}
  • A query is constructed by concatenating several Contact record Ids, separated by a single white-space. This query is meant to search for all Contact Objects that are related to the corresponding Account object.

  • The code snippet below shows how the query is represented in code.

Search Refinement

There are multiple ways to refine the search by modifying the parameter q. This permits you to:

  • Search for images in one or more specific albums

  • Search for images having specific tags

  • Search for images taken on specific dates.

The following examples demonstrate how to refine the search:

  • Search for images found in specific albums

    • Suppose we have albums with IDs albumID , albumID 1 and albumID 2 and we want to search for images found only in albumID and albumID 1. To do so, we have to modify the parameter q as shown below:

circle-exclamation
  • Search for images having specific tags

    • Suppose we want to search only for images with tags names Tag1 , we have to modify the parameter q in the code as shown below:

  • Suppose we want to search only for images with tags names Tag1 and Tag 2, we have to modify the parameter q in the code as shown below:

  • You can also search for images with either Tag1 or Tag2 using the code snippet below:

  • Search for tagged images found in specific albums

    • The example below shows how you can refine the search in order to search for images having tag Tag1 in albums with IDs albumID and albumID 1 only.

  • Search for images taken on specific dates from specific albums

    • The following example demonstrates how you can enhance the search criteria to specifically look for images taken on certain dates from 'Jan 01, 2024' to 'Feb 01, 2024' within albums with IDs albumID 1 and albumID 2 only.

Enable download and zipping

It is possible to download the search image results into a zipped folder through the use of the following parameters.

  • download - (true or false ) enable or disable the download feature.

  • download_filename - specify the name of the downloaded image file (only 1 image)

  • download_filenames - specify the name format of the downloaded image files (multiple images)

circle-check

Visualforce Page

  • The code snippet below shows the implementation of the Visualforce Page used to display the search results on a SharinPix Album.

circle-check

Last updated

Was this helpful?