Forums

HTML coding question? (8 posts)

  1. monkeymartin@gmail.com
    Member
    Posted 3 years ago #

    I am starting to put a lot more complicated HTML code into my posts. This cod is making it harder to make changes and fix problems. I separate the sections of a post into multiple pages. I tried shearing on Google but I don't know what to search for.

    Example:
    I have a table with some data. Instead of typing out all this information in the post I would like to have a separate HTML file that imports all of the code into my post. This way the post stays clean. I don't want to just link to the information I would like it to be part of a signal post.

    Thanks for your help

  2. jamesbruno
    Member
    Posted 3 years ago #

    One thing I could suggest is making your own page templates. This way you can have all of the structure in the template and then just add your information from wordpress.

    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    Anthony

  3. moronicbajebus
    Member
    Posted 3 years ago #

    I haven't tested the following, but sounds like the basis of what you need in a plugin:

    /**
     * ... Plugin info
     *
     * Shortcode to include a file contents into the post when outputted.
     * [include src="internal/path/to/file.html"]
     */
    
    function shortcode_include_func($atts) {
    	extract(shortcode_atts(array(
    		'src' => '' // set the default to an empty string
    	), $atts));
    
    	if(!empty($src)){ // make sure $src is not an empty string
    		return file_get_contents($src); // return the file as a string
    	} else {
    		return '';
    	}
    }
    add_shortcode('include', 'shortcode_include_func');

    A) I haven't tested this at all.
    B) There needs to be error checking to make sure the file exists.
    C) The path will be confusing to most people. Perhaps best if it was to match the URL path instead of the internal path.

  4. monkeymartin@gmail.com
    Member
    Posted 3 years ago #

    The page template is a good idea but most of the pages are going to be different.

    I would like to create multiple HTML pages just like you can create multiple CSS Style sheets. You have one main Style seat and import the rest like this

    @import url(main.css);
    @import url(layout.css);
    @import url(color.css);

    Is their a way to do the same thing with HTML

  5. mrmist
    Forum Janitor
    Posted 3 years ago #

    Not really, but you can do it in PHP.

  6. monkeymartin@gmail.com
    Member
    Posted 3 years ago #

    How do I do this in PHP and can I put PHP in a post.

  7. mrmist
    Forum Janitor
    Posted 3 years ago #

    See http://www.php.net/include/

    You can't normally write PHP code in posts, you'd need to either do it in templates, or use an exec php plugin which would let you put it into posts.

  8. monkeymartin@gmail.com
    Member
    Posted 3 years ago #

    I found this http://www.webhostingtalk.com/showthread.php?t=508687

    I think I will have to live with all the HTML tags in my posts. Having to install a plug-in and run PHP will make life more complicated

    Thanks for the help

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags