Admin Media Predefined Search

From TNG_Wiki
Revision as of 22:45, 8 October 2018 by Rmcrae (talk | contribs) (Added new mod templates, and boilerplate how to update cust_text.php to TNGv12 specs)

Jump to: navigation, search

Template:RobinV12 cust text update

Admin Media Predefined Search
Summary Adds a dropdown box to the Admin Media Search form that populates the search box with strings intended to do multi-valued searches for media objects of a particular media type. It is intended to facilitate reassigning new media items to a different category after a Gedcom upload.
Mod Updated 4 May 2018
Download link
TNG 12.0
TNG 11.0
TNG 10.1.0
Download stats
Author(s) Robin Richmond
Homepage Robin Richmond's Genealogy Database
Mod Support My Mod Support form or TNG Community Forums
Contact Developer My Mod Support form
Latest Mod &
Min TNG V 10.1
Max TNG V at least 12.0
Files modified
admin_media.php, English cust_text.php
Related Mods

Purpose of the Mod

To make it easier to fix improperly categorized Media Items (i.e. those with wrong media type). By the way, in this context, the term "collection" is equivalent to "media type".

Because of the way that I edit data and create GEDCOMS (that is, with Family Tree Maker), all of my media items (for a given tree) are in a single media folder, and the TNG GEDCOM import process is unable to effectively categorize my media items. TNG's GEDCOM import process does use file extensions to assign the media type of new media items, but all new .JPG's are identified as "photos". So, I often wind up with numerous improperly-categorized media items.

To re-categorize items, I search the "photos" collection for strings such as "stone", "grave", and "cemetery" to try to find headstones, and for strings such as "history", "notes", "story", or "obit" to try to identify "histories". This searching is not completely accurate, of course, and it is laborious.

This mod effectively automates that search scheme. In particular, it adds a drop-down box to the Administration >> Media search form that allows the user to select search strings customized for a particular media type. Those search strings contain comma-delimited keywords that are each searched for independently. That is, the comma acts like an OR operator.

Compatibility With Other Mods

This mod is fully compatible with Unused Media, Admin Media Search, and Private Media Mod, the only other mods that affect admin_media.php.

Dependencies on other Mods

This mod generates that can be used by the Show Mod Names mod, which is completely optional.

Related Mods

  • Gedcom Import Mediatype is specifically designed to help make process of reassigning Media Collections easier. It allows you to specific a rarely used mediatype (say, Videos) as the default for new media items in a Gedcom Import. With new media items assigned to, say Videos, instead of Photos, it will be much easier to identify the new items that need to be reassigned. You still need this mod (or a more manual process), but Gedcom Import Mediatype helps to distinguish new media items from old ones.
  • Admin Media Search also affects the Admin Media Search, and is more widely applicable than this mod.

[Show Installation Details]


  • A working TNG installation.
  • An installed current version of the Mod Manager.
  • You should backup files listed in the panel on the right.


  1. Remove and delete previous version of this mod.
  2. Backup the files updated by this mod. They are listed in the panel at the upper right.
  3. Download the .zip file, Extract its .cfg file to the mods folder.
  4. Follow the normal automated installation for Mod Manager, as shown in the example Mod Manager - Installing Config Files.


  1. Try using the Mod Manager Remove capability
  2. Contact me through My Mod Support form.
[Hide Details]


Admin media predefined search-after.png

Note the highlighted drop-down list. Only one entry is shown when the page is loaded; it has been expanded to list all of the predefined search choices. When "Headstones" was selected, the related search string was stored in the Search field in the form.

Note also that the use has selected the collect "Photos", since (without Gedcom Import Mediatype) most new Media Items are assigned to "Photos" (in the single-collection-folder environment that this mod was designed for).

The user must also select the Mediatype that the photos matching this search will be moved to. In this case, it is set to "Headstones" (on the bottom row of buttons in the screen clip).

When the user clicks on "Search", the search results will list Photos that have the words "stone", OR "tomb", OR "grave", OR "burial" (etc) in the Media table description, path, notes, or bodytext fields. These results are (we hope) likely to yield Headstone photos, which belong in the Headstones collection. Upon seeing the results, the user can select the Photos that should be moved, and move several at once.

The search strings

The Admin Media Search form search the description, path, notes, and bodytext fields of a media item for one search string.

The following lines in the English and English-UTF8 versions of cust_test.php define a single string named 'presearchvalue' that contains multiple multi-valued, case-insensitive search strings.

$admtext['presearchvalue'] = "Census:census,ennumeration";
$admtext['presearchvalue'] .= "\nHeadstones:stone,tomb,grave,memorial,burial,cemetery,marker,crypt,resting place";
$admtext['presearchvalue'] .= "\nDocuments1:index,births,deaths,marriages,U.S.,records,registration cards";
$admtext['presearchvalue'] .= "\nDocuments2:death collection,marriage collection,certificate,license";
$admtext['presearchvalue'] .= "\nDocuments3:register,tax list,border crossings";
$admtext['presearchvalue'] .= "\nHistories1:bio,history,histories,memoir,notes,story,obit";
$admtext['presearchvalue'] .= "\nHistories2:article,letter,will ,will$,wills,probate";

Each line in the 'presearchvalue' string will be presented to the user as an option in the new the new drop-down box called "Preloaded Searched" on the Admininstration >> Media Search form. If you select "Headstones" from the drop-down box, the program will search for "stone" OR "tomb" OR "grave" (etc.).

To accomplish this, the modified code places the keyword "OR:" at the front of the multi-valued search string. The keyword "OR:" is not a search term, but it tells the program to treat the rest of the string as a series of comma-delimited search terms, each of which will satisfy the match. Thus, with this mod installed, not only can you select one of the predefined search terms, but you can also simply simply type OR: at the beginning of a comma-delimited search string of your own, and force the program to search for ANY of the search terms, rather than the search string as a whole.

Note that

  • A normal search looks in five fields in the Media table - mediaID, description, path, notes, and bodytext fields. Preloaded searches, however, do not search the mediaID field.
  • You might want to remove the term the term "stone" from the "Headstones" search string if you have a "Stone" family in your database. The same goes for the term "story" in the "Histories" search string.
  • The term "will " in the "Histories2" search string contains a space so that names like "William" don't cause false matches.
  • The dollar sign in the term "will$" in the "Histories2" search string represents the end of the target string, just like it does in regular expressions. Given that "will " has a space at the end, "will$" allows the search to match "John Brown's will", while not matching "William".
  • The search terms "will " and "will$" will, however, match "Will Smith Death Certificate".

To modify the search strings, you should create entries at the bottom of your cust_text.php file that completely redefine $admtext['presearchvalue']. That is, you should start with a line such as

$admtext['presearchvalue'] = "Census:census";

followed by each additional search string, using the "assign and append" operator, ".=", and placing a colon after the search label (Census, Headstones, Documents1, Documents2, etc.).

Mod Change History

*** The newest version of the mod is at the top of this table ***

Mod Version TNG Version Date Note 12.0+ 4 May 2018 No functional changes; made compatible with TNGv12. 10.1 - 11.1.2 1 Dec 2017 Removed the second line from the cust_text.php target location search string.

Also repositioned the Predefined Search field in the form layout table to be compatible with a new version of Admin Media Search. 10.0.3 - 10.1.3 21 Feb 2016 The predefined strings dropdown list now maintains its selection after search and page operations within a search.

I also tweaked some of the predefined searches. This mod now uses (and depends on) Show Mod Names v2+. 10.0.3 - 10.1.2 01 Sep 2015 Added some search terms, and implemented special processing for "$" at the end of a search term to anchor that term to the end of a target string. 10.0.3 - 10.1.1 08 May 2015 Initial release.

Sites using this mod

If you download and install this mod, please add your site to the table below.=

URL User Note Mod-Version TNG-Version User-language
Robin Richmond's Genealogy Database Robin Richmond Mod developer 12.0.0 English