Welcome Guest, Not a member yet? Register   Sign In
modify static content

I want to include an ordinary html file, but only keep the code between <body> and </body>. I don't know what's the best way to do this?

Secondly I want to change url's to static content in the include html. So:
<img src="test.jpg" alt="test" />
<a href="about.html">...
should become
<img src="http://www.mysite.be/blah/test.jpg" alt="test" />
<a href="http://www.mysite.be/about/">...

Shoud I do this with a regular expression or are there easier ways?

Thanks a lot,


[eluser]sparkling tux[/eluser]
Seems you static content is a bit dinamyc, nevertheless Smile

I'd make them (your html pages) all *.php and would load them using $this->load->view.

In your *static* files in the link tags I'd insert

In the config.php I'd set
| URL suffix
| This option allows you to add a suffix to all URLs generated by Code Igniter.
| For more information please see the user guide:
| http://www.ellislab.com/codeigniter/user-guide/general/urls.html

$config['url_suffix'] = "html";
as soon as you want your urls to have .html on the end.

sparkling tux, while seeing the like side of your situtaion with his firts line, summarised your issue here.

Whichever way you usem you are going to pass this file through some kind of parser.

Why not kust convert it to a view.

<img src="&lt;?php echo $path; ?&gt;test.jpg" alt="test" />
<a href="&lt;?php echo $path; ?&gt;about.html">...

Or, your could use the &lt;base&gt; html tag. <Favourite search engine> is your friend here

Hmm, that's not really what I want. I was asked to built a simple static site, but still I wanted to avoid writing the same code over and over again. Another requirement was that the site content should be easy to update with some basic html.

So I've made basic a static site, something like this:

I want to use CodeIgniter to add a menu, header, automatic breadcrumbs, links to sylesheets, a footer ... to all of these html files. All the html files really provide is the content (<div id="content">this part</div>).

I want to keep them full blown html files so the content providers can simply launch them in any browser to preview (see that links, images, ... are set correctly).

I redirect all request (except thos for images, css-files, ...) to one controller. The request url tells is whitch html file to load, what the breadcrumbs are and which menu-item is selected.

For now I'm using the following to get only the part between the body tags out of the html-files:

$string = file_get_contents($url);    
        if (!preg_match("/&lt;body&gt;(.*)<\/body>/s", $string, $match))
            return "FALSE";
        return $match[1];

Next I'll have to adjust links to static content so it maps nicely to correct url on the server... . I'll be regular expressions for this, but I don't know what the perfomance penalty will be. Maybe I should build a sort of caching system... .

I have suggested in some other thread the same solution for urls in javascript and css files. The trigger i proposed was the pre system hook but it's not necessary for there files to get checked every time a page loads.

i think in your case you could write a script where you check when the file is modified last and compare it to the last rewrite. This way you can upload as many html files as you want and let the script do the heavy lifting for you.

I would work with placesholders in the html files to make the replacing a bit easier.

[eluser]sparkling tux[/eluser]

To my mind, you're overcompicating the things. PHP was initially created as templating system to let solve the tasks, you're trying to fulfill using regexp, much easier and faster.

Theme © iAndrew 2016 - Forum software by © MyBB