Jump to content
TNG Community
LeslieP

Custom Media Collections - files assigned via GEDCOM import

Recommended Posts

LeslieP

I have finally found a way to get my media files assigned to the proper custom media collections during the GEDCOM import process.

It does require a "hack" to the gedimport_misc.php file, maybe someday the capability can be made standard by Darrin, or turned into a mod, but for now, this is a HUGE thing for me. I've never cared for the documents/video/recordings collections, always wanted to use my own collections and menu items.

Since I use TNG just for display, and frequently clear the tree and reimport from GEDCOM, I needed the placement of files into collections to be automated and not manual. Now it is. I wrote it up in a longer blog post with lots of screen shots, and I'm afraid it probably still doesn't make too much sense, but thought I'd offer it here for anyone looking to do this.

Say I have images of birth certificates and the like on my desktop in P:\Genealogy\exhibits\birth_records, and my genealogy program (RootsMagic) puts that entire path in the GEDCOM file. I really want to have a media collection and menu item called "Birth Records", and for the GEDCOM import to put those files in that collection for me. Here's how

  1.  make the server folder structure similar to the desktop folder structure
    on desktop: P:\Genealogy\exhibits\birth_records
    on server: tng/documents/birth_records
  2. create the collection in TNG Admin>>Media
    collection ID: birthrec
    display title: Birth Records
    folder name: documents/birth_records
  3. add code to customconfig.php defining this collection and the gedcom file path
    $locimppath['birthrec'] = "P:\\Genealogy\\exhibits\\birth_records";
  4. edit gedimport_misc.php to add this collection ID and import path info to the getLocalPathList function

This is what gedimport_misc.php section looks like original:

function getLocalPathList($mediatypeID) {
    global $locimppath, $mediatypes_locpaths;

    switch( $mediatypeID ) {
        case "photos":
            $locpath = $locimppath['photos'];
            break;
        case "histories":
            $locpath = $locimppath['histories'];
            break;
        case "documents":
               $locpath = $locimppath['documents'];
            break;
        case "headstones":
               $locpath = $locimppath['headstones'];
            break;
        case "recordings":
        case "videos":
            $locpath = $locimppath['other'];
            break;
        default:
            $locpath = isset($mediatypes_locpaths[$mediatypeID]) ? $mediatypes_locpaths[$mediatypeID] : "";
    }

    return $locpath;
}

You need to add a "case" section for your new media collection. This is what you add:

        case "birthrec":
            $locpath = $locimppath['birthrec'];
            break;

Do that for every additional media collection you have created.

This is the longer blog post about this technique https://lptex.com/blog/tng-custom-media-collections-using-gedcom-import/

Here's what I see after I do a GEDCOM import and then run the secondary process to trim menus

screenshot_20191125_014.png

And this is what the menu looks like on the live site

screenshot_20191125_001.png

 

I'm working towards the TNG-WP integration and will not be using the TNG menus at all, so I didn't bother with any menu icons.

I hope this helps others as much as it has me - this is something I've wanted for YEARS and finally sat down to figure out how to do it myself.

Share this post


Link to post
Share on other sites
TBirdUK
On 11/26/2019 at 4:35 PM, LeslieP said:

I hope this helps others as much as it has me - this is something I've wanted for YEARS and finally sat down to figure out how to do it myself.

It has certainly helped me, many thanks for this delightfully clear explanation of the process, I estimate this will save me hours a week. 

Wouldn't it be wonderful if someone with the skills turned this into a mod that used the tng_mediatypes table as source and configured the 2 files automatically? 

Share this post


Link to post
Share on other sites
fluffy82

This seems overly complicated. I use the same tree structure in Family Tree Maker on my PC as on the server of my website. Never had any problems at import, the media always link to the correct folder and hence collection.

Share this post


Link to post
Share on other sites
LeslieP

It IS complicated, stupidly so.

I've always had fully functional media links, just not the collections. I clear my tree prior to an import, which removes all the media. Before I did this convoluted setup, collections were empty, the import would not put the files into the collections.

Is there some easy way to do that?

Share this post


Link to post
Share on other sites

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

×