ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Embedding HTML tables

December 01, 2011 12:17pm

Subscribe [3]
  • #1 / Dec 01, 2011 12:17pm

    Chris Malumphy

    16 posts

    I have numerous HTML tables created and stored outside of EE. I would like to be able to create a single display template that could embed the appropriate table that I would designate by providing a variable with the pathname. Can that be done.

    For instance, my selection template would contain a list of the tables that could be chosen. Once a selection is made, the path could be passed to my display template which would have a standard header, sidebar, and a content area to display the selected table. My tables are stored in standard directories outside of EE ala

    Years
    ..2011.html
    ..2010.html
    ..2009.html
    College
    ..Albany.html
    ..Alcorn.html
    ..etc

     

  • #2 / Dec 02, 2011 2:04pm

    Dan Decker

    7338 posts

    Hi Chris Malumphy,

    I’m afraid that isn’t something that would really be possible due to the security risk it represents. The better option would be to store those same tables in templates as well. It is completely possible for templates to store static content. Doing that would also allow you to use ExpressionEngine tags in those tables if your desire, anding to the flexibility and dynamic nature.

    Thanks!

  • #3 / Dec 02, 2011 4:48pm

    Chris Malumphy

    16 posts

    Dan,

    Thanks for the reply. I am trying to avoid the need to store my html tables in templates, possibly because I’ve never tried it, but also because I have over 1,000 separate html tables, each of which needs to be updated a few times a year.

    I’ve been experimenting with the php include command and segments. My “selection” and “display” templates are currently one and the same and include a bunch of links in the form “http://www.site.com/index.php/directoryName/filenameWithoutExt/” that allow the user to pick the table they wish to view. After the user selects the table they want by clicking on a link, my EE template parses the url segments and then inserts the correct html table into the display code.

    if segment_2 != ""}
            <?php include("{segment_1}/{segment_2}.html"); ?> <!--include table-->
     <?php include("{segment_1}.html"); ?> <!--include html code to easily select related tables -->
    {if:elseif segment_1 != ""}
     <?php include("{segment_1}.html"); ?> <!--if just one segment, it means that their are many subSelections to be displayed and selected from. i.e. If user selected years, then years 2011, 2010, 2009, etc are displayed so user can choose from among them-->
    {if:else}  <!--if user didn't select table to view then display recent articles-->
            {exp:channel:entries channel="articles" limit="6"}
                    <h2>{title}</h2>
    <p>                </p><h5>By {author}</h5>
    <p>                {article_body}<br />
            {/exp:channel:entries}<br />
    {/endif}

    But this whole structure is likely to breakdown, explode, very quickly once I have more than one template or channel. It already has problems when some of the html tables are not related to any others and thus don’t get placed in separate directories and don’t have related items to display (meaning there is never a segment_2), because my if statement throws of errors in instances where there is no {segment_1}.html file (which happens when there are no related tables to select from).

     

  • #4 / Dec 05, 2011 8:47pm

    Sean C. Smith

    3818 posts

    Chris,

    If you have your templates set to save as files then you could put all of your tables into a folder inside the templates folder, lets call it tables. Then in your Control Panel go to Design > Templates > Syncronize Templates and sycronize your templates they would all appear in the database.

    The only thing here is then you would have to adjust your code to not have the .html file extension.

    Let me know if this helps.

    Sean

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases