Skip to main content

Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #194106
    bearhead
    Participant

    Hey, this isn’t a js question per se, so I put it in this forum.

    I’m working on a website for my engineering firm that has over 300 separate pages for their projects. In order to improve maintainability, I created one “template” page for all the projects. That template gets included via php on to a projects file’s index.html page, and then content is inserted in via javascript.

    It is kind of convoluted, but the benefit is that if my boss wants something changed that requires editing html, I only need to do it once to the template document and not 300 times to each project file.

    However, this make the site pretty much totally dependent upon javascript… is that smart? Should I be going about it in a different way? Is there an equivelent to this script: $(".quote").load("project_data.html #quote"); in php I could use?

    here is an example project so you can see what I have going on: http://www.aeieng.com/new_aei/project1/

    #194122
    Shikkediel
    Participant

    This answer on Stackoverflow looks like a php alternative :

    http://stackoverflow.com/a/9539996/3168107

    And yes, it’s probably a better approach then loading everything with JavaScript. If only for general search engine indexing…

    #194343
    Paulie_D
    Moderator

    What I need to do is take the content from specific divs on one document, and then insert it into other specific divs in another document.

    Ugh…

    The answer Shikkediel gave was specifically stated to be a PHP alternative which is designed to use templates like that.

    It’s gotta be a much better option that this “cloning” or “cut and pasting”.

    #194345
    Shikkediel
    Participant

    If the original HTML files should be kept as they are, it’s probably preferable to use file_get_contents so the data can be ‘hacked up’. To be able to discern the elements from each other, we come into an area I know little about – one would need a regex or parser library.

    Were the job up to me, I’d make smaller templates of the original files and insert them separately into the document – with the readfile method or include with echoed HTML even.

    Edit – also in response to nkrisc, I think this is a basic CMS of sorts…

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Other’ is closed to new topics and replies.