GallerySearch for CE3

The current incarnation of my website exists due to the power of The Turning Gate‘s (TTG) Lightroom web plugins. One of its features is the open framework that allows extension. In the past I already wrote about how I customized my site using something called phplugins:

But there is one feature that so far is not available from TTG and that I really missed: image search. Curious in nature and with my technical background, I had looked at this in the past and finally decided to go after it. I am happy to say that I successfully added image search to my site and I put some additional effort in it so that you can use it as well! This is how it looks like:

GallerySearch for CE3 Example

If you like to see search live, please head over to my search page.

Getting Started

GallerySearch for CE3 is a search module that plugs into The Turning Gate’s CE3 powered websites that use the CE3 Gallery and CE3 Publisher components. This is the easiest way to add image search to your website. It integrates smoothly into your existing site and uses the same layout as your gallery pages.

Features:

  • Simple installation, no custom coding required!
  • Searches caption, title, filename and keywords
  • Shows matching image galleries and search terms
  • Results displayed using CE3 Gallery view
  • Search results pages support TTG CE3 Cart integration
  • Supports Google Maps, permalinks and Pinterest on search results pages
  • Creates log files for search usage analysis
  • Compatible with Google Analytics

The search engine uses following rules:

  • All search terms must match (and)
  • Search is not case sensitive
  • Search covers following fields: caption, title, filename and keywords.
  • Performs substring matches: e.g., searching for ‘school’ returns matches for ‘schoolyard’ too

Requirements

It is always good to use the latest version of TTG CE3 Gallery and TTG CE3 Publisher. But TTG CE3 Gallery 5.2.3 or above is required in order for GallerySearch to work.

Limitations

Please be aware of:

  • GallerySearch for CE3 is totally dependent on the TTG CE3 Gallery and Publisher. If TTG changes the internal operation of their Lightroom plugins, GallerySearch might become unusable. There is no guarantee that future versions of TTG CE3 Gallery can be supported! I will do my best, but there is no guarantee that it can be done!
  • GallerySearch for CE3 works well for a small site like mine that don’t have tens of thousands of images and don’t get a lot of traffic.
  • Language localization is not supported
  • If TTG CE3 Cart support is enabled in the GallerySearch for CE3 configuration file, it assumes that all images are for sale! For images that are not for sale, set their Category field to not-for-sale and make sure that Mixed Pricing is enabled.
  • Galleries that require a password for viewing are not indexed and therefore are excluded from the search.
  • GallerySearch for CE3 is designed to work only with TTG CE3 Gallery managed by TTG CE3 Publisher!
  • TTG CE3 Gallery is used to display the search results. Currently, Download Hi-res Images is not supported.

Shop

Gallery for CE3 can be purchased in the TTG shop.

With the release of TTG CE4, GallerySearch for CE3 is no longer available at The Turning Gate store. I have setup my paypal store where you can buy it for $25.

All sales are final, no refunds. Only available as a digital download.





Installation and Customization

Thanks to some modifications that Matthew did to TTG CE3 Gallery, installation and integration of GallerySearch for CE3 is simple! Thank you, Matt, for doing this!

1. Zip file

Once you have unzipped the zip file, you should have a ‘GallerySearch-x.x.x’ folder with a subdirectory called ‘search’. FTP the ‘search’ subdirectory to the root of your website which is the default location for GallerySearch.

2. Gallery Template

To integrate the search feature into your website, gallery template files are used. In Lightroom, open your current Gallery Template you use for your gallery pages.

In the Appearance panel, disable following feature:

  • Download Hi-res Images

In the Output Settings panel, disable following feature:

  • Enable Password Protection (not checked)

Next, using the Template Browser, I would save these modifications as a new template. Then export this template to your computer and upload it to your site using your favorite FTP software. The template files belong into ‘/search/templates/’.

3. Edit Configuration File

Open the file ‘/search/config/config.php’ in a text editor and adapt it according to your site’s settings:

  • ADMIN_KEY is a special key needed to access the administrator page.
    define("ADMIN_KEY", "GallerySearch");
  • GALLERY_DIR defines which gallery or galleries are included in the search operation. The path starts in ‘/search’ directory.
    define ("GALLERY_DIR", "../galleries");

    is the default setup where only one gallery folder called ‘galleries’ is available. With

    define ("GALLERY_DIR", "../galleries, ../events");

    a second gallery folder ‘events’ is added to the search list. If you have more gallery folders, just add them inside the second set of double quotes. The path to the gallery folders starts in the search directory.

  • EXCLUDED_DIR can be used to exclude certain galleries from the search. I use it to exclude my test galleries and private pages.
    define ("EXCLUDED_DIR", "galleries/test, galleries/private");
  • PRIVATE_KEYWORD_PREFIX. As the name says, this is used to eliminate private keywords. For my site, I use the convention that all private keywords start with an ‘_’. If you have more than one prefix, you can separate them with a single coma.
    define ("PRIVATE_KEYWORD_PREFIX", "_");
  • ENABLE_CART. The CE3 shopping cart works on search results.
    define("ENABLE_CART", "no");

    As already noted before, if cart support is enabled, it works on ALL image independent of the respective gallery settings. If you have images that are not for sale, you have to set the Category field to not-for-sale.

  • CART_TEMPLATE sets the name of the gallery template used to show search results. This is the name of the gallery that is located in the ‘/search/templates/’ directory.
    define("CART_TEMPLATE", "my_gallery_search_template");

    Note: In order that the search results look nice, it is recommended that all your image galleries use the same gallery template.

4. Create search index

Open ‘http://my_web_site.com/search/admin’ in your favorite web browser and enter your Admin Key and click on ‘Build Index’. A few configuration checks are performed to verify that your setup is correct before the search index is generated. An error message indicates if something went wrong. That’s it! The installation is complete and ready for use. Go to ‘http://my_web_site.com/search’ and try to find your images.

Whenever you make changes in Lightroom and publish them to your website, you have to recreate the search index!

Tip: bookmark the admin page after a new search index was generated. Whenever you select this bookmark, a new search index is generated!

5. Add Search Entry to Menu

Now that searching images is working, you might want to integrate the search into your navigation menu as well!

  • Using a search link
    In order to select the search from your main menu, add a menu entry that links to ‘/search/search.php’.
  • Adding a search field
    If you would like to add a search field on the front page, the custom menu or the header, a few lines of custom code will do the trick:

    <form method="get" action="/search/search.php">
    	<input type="text" name="q" value=""/>
    </form>
  • Adding an entire search form
    If you want to use an entire search form including the search options on one of your pages, maybe on your main gallery index page, use following code:

    <form class="search-form" method="get" action="/search/search.php">
        <input class="search-rb-full" style="margin-left:8px; margin-right:8px;" type="radio" name="t" value="0" checked/>Full text<input class="search-rb-keywords" style="margin-left:24px; margin-right:8px;" type="radio" name="t" value="1" />Keywords only<br>
        <input class="search-text" type="text" name="q" value=""/>
        <input class="search-submit" type="submit" value="Search"/>
    </form>

6. Look & Feel

The default look and feel of the search form is gallery_search_standard
Using phplugins and CSS, one can easily change the look and feel. Maybe you would like to add a border and change the background color:

gallery_search_box
To achieve this effect, I added following few lines of code in my ‘custom.css’ file:

.search-grid{
	border-color: black;
	border-style: solid;
	border-width: thin;
	border-style: solid;	
	background-color: #BCC6CC;
	margin-top: 20px;
	margin-bottom: 20px;
	padding: 20px 15px;
	border-radius: 10px;
	width: 80%;
}

The Gallery Matches and Image Matches lists can be styled with a little bit of CSS code that needs to be added to your ‘custom.css’ file. This example shows the results iwthout bullet points as horizontal lists:

GallerySearch_matches

  • No bullet points:
    .search_matches li {
       list-style-type: none;
    }
  • Horizontal lists:
    .search_matches li {
       display: inline;
       margin-left: 0.5em;
       margin-right: 0.5em;
    }

    Adjust the margins to best fit your layout.

In order to use custom CSS code, PHPlugins and custom.css need to be enabled.

7. Content Area/”The Block”

The default text in the block area above the search form can be replaced by the user. Create the file ‘search.html’ on your computer and add your content in either HTML or Markdown format. Then upload search.html to your website to ‘/search/config/search.html’.

8. GallerySearch Identifier for PHPlugins

The GallerySearch plugin defines the GALLERYSEARCH_FOR_CE3 identifier. This can be used within the PHPlugins framework to target the search page.

9. Using Google Analytics’ Site Search to analyze GallerySearch usage

Google Analytics can be used to analyze GallerySearch usage on your site. Setup is easy and I have summarized the setup over on my blog.

Support

Please have a look at the frequently asked questions section as it might already contain the answer to your question. Otherwise post your question in the GallerySearch for CE3 section of the TTG community forum

Licensing

  • Each domain needs its own license. Sub-domains don’t need a separate license as long as they serve the main site (e.g., if you host a sub-domain for a friend, your friend would need his own license).
  • GallerySearch for CE3 may only be used with TTG CE3 powered web galleries.
  • THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version History

GallerySearch-1.1.0:

  • Added support for Google Maps
  • Enhanced setup checks and refined error reports

GallerySearch-1.0.1:

  • Fixed: Using phplugins with WordPress generated menu structure generated errors
  • Fixed: Index generation failed with single image galleries

GallerySearch-1.0.0:

  • Added GALLERYSEARCH_FOR_CE3 define for search page identification in phplugins
  • Added styling attributes to radio-buttons

GallerySearch-0.9.3:

  • Fixed: query-string was not properly propagated to paged results
  • Fixed: new search didn’t clear current page number

GallerySearch-0.9.2:

  • Changed search index handling to support galleries with a lot of images
  • Added pagination to search results

GallerySearch-0.9.1:

  • Added check to verify empty gallery root pages
  • Added support for PHP 5.2.x
  • General stability improvements
  • Removed dependency on hardcoded autoindex template name
  • Refined operation with gallery template files

GallerySearch-0.9:

  • Updated to work with standard gallery template files. This version
    doesn’t need the gallery grid and keywords modification anymore.

Frequently Asked Questions

Over time, this FAQ section will grow based on your questions.

  1. Admin page say: xxx directory is not writable!
    Using your FTP tool, change the permission of the given directory to either 755 or 777. If the first one doesn’t work, try the second one.
  2. Admin page say: xxx directory is not readable!
    Using your FTP tool, change the permission of the given directory to 555.
  3. I use TTG CE3 Gallery 5.2.3 but keyword search does not work!
    When updating to TTG CE3 Gallery 5.2.3, all images need to be re-published. If you set the Publisher setting ‘Push metadata without updating existing photos’ then this step should be very fast.
  4. Warning: Gallery XXX doesn’t look like a Publisher managed gallery installation!
    GALLERY_DIR must point to Publisher managed galleries.
  5. This is not a Publisher managed image gallery!
    GallerySearch only supports Publisher managed image galleries. Galleries that are created and exported from Lightroom and manually transferred to your web server using FTP are not supported!