Support » Plugin: HTML Import 2 » [Plugin: HTML Import 2] Preserving directory hierarchy

  • Resolved Mark Tuttle


    I’m unable to get version 2.2 to preserve the directory hierarchy.

    Under settings->html import->files I set
    directory: c:\www\host\path
    old url: http://host/path
    default file: home.html since http://host/path/home.html is the main file

    Under settings->html import->metadata I set
    Import pages as children of: None (top level)

    The result is 11 new pages as children of the top level, and not the former home.html as child of the top level and the remaining 10 files in the directory as children of the former home.html.

    This use to be quite easy. Any idea what I could be doing wrong this time?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Looking at method get_post($path,$placeholder) in class HTML_Import in html-importer.php

    // if we're doing hierarchicals and this is an index file of a
    // subdirectory, instead of importing this as a separate page, update
    // the content of the placeholder page we created for the directory
    if (is_post_type_hierarchical($options['type']) &&
        dirname($path) != $options['root_directory'] &&
        basename($path) == $options['index_file']) {
    	$post_id = array_search(dirname($path), $this->filearr);
    	if ($post_id !== 0)
    		$updatepost = true;
    if ($updatepost) {
    	$my_post['ID'] = $post_id;
    	wp_update_post( $my_post );
    else // insert new post
    	$post_id = wp_insert_post($my_post);

    it seems that files in the root directory are not made children of the index file in the root directory, because no placeholder post gets made for the root directory, so there is no existing post to update with wp_update_post. Am I reading this correctly? So by design the hierarchy in for root directory must be constructed manually?

    Plugin Author Stephanie Leary


    Yes, the handling of top level files is inconsistent with subdirectory files. I think this makes sense; any top-level files would have originally had URLs like http://host/path/file.html, and you (most likely) wouldn’t want those to end up at http://host/path/home/file.html, which is where they’d be if they became children of the default file.

    It is of course possible that I haven’t thought through all possible scenarios… 🙂

    Mark Tuttle


    I see. That is not my experience, but I understand your explanation. It would ordinarily be a very minor issue, except that I import large sites subtree by subtree over extended periods of time as I and other volunteers hack the archaic html to meet modern standards before importing. Perhaps the most elegant solution is to insert a line into the documentation (even into the configuration page?) mentioning this distinction so the next guy like me (if there ever is one) is not surprised.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: HTML Import 2] Preserving directory hierarchy’ is closed to new replies.