Jump to content
TNG Community

Custom Media Collections - files assigned via GEDCOM import


LeslieP

Recommended Posts

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.

Link to comment
Share on other sites

  • 1 month later...
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? 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

  • 8 months later...

thanks again, having just upgraded to v13 site I spent a stupid amount of time trying to remember which mod I had installed that routed the media types correctly!
Not sure if v13 is attempting to do the same thing as the code in gedimport_misc.php has changed a lot, but it is not working for my Gedcom?
 

Link to comment
Share on other sites

  • 5 months later...

@LeslieP Hi, I'm new to TNG (just picked it up this weekend so I am running v.13.0.3) and have been tearing my hair out regarding custom collections and the import process after trying various things I found this post and tried out your process.  It worked beautifully first time!
Many many thanks to you!
 

gedcom import custom collection success.jpg

Link to comment
Share on other sites

  • 2 years later...

@LeslieP your post here and particularly your blog post linked herein are extremely useful for me.  THANK YOU!!

Might anyone know if the php file-edit procedure works the same with v.14?  

Lealie’s use-case is EXACTLY that of my own, which is to say; I desire zero-maintenance semiregular tree imports to TNG that will nevertheless accommodate custom collections (created in TNG prior to import) and render associated media without manually servicing the media files (for custom collections) in TNG after each import.

It appears the .php file edit is the answer I’ve been looking for.

I use Reunion and TNG v. 14, but our end goal is the same.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...