CodeIgniter Forums
Create .html pages - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Create .html pages (/thread-60256.html)



Create .html pages - El Forum - 02-15-2014

[eluser]Unknown[/eluser]
Hi there,

I've been looking on the internet for help with this. Too bad i couldnt find anything helpfull.

I've got a page controller and i'm using the template builder.
Now with my page controller

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Page extends CI_Controller
{
    
    public $layout  = 'default';
    public $templateName;
    
    public function __construct()
    {
parent::__construct();
$this->template->set_layout($this->layout);
    }
    
    /**
     * Index page
     */
    public function index($page = 'default')
    {
$this->templateName = $page;
$this->template->title('Websitea');
$this->template->build($this->templateName);
    }        
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */

And my routes.php

Code:
$route['page/(:any)']   = 'page/$1';
So in my view dir i've got a 'default.php' template, that will be the homepage, now i want to make more pages, like about-me, i got the file 'about-me.php' also in my view dir.

What i want now, is that i can visit localhost://[websitename]/about-me.html and that would the load the about-me.php template.
Because now its like localhost/[websitename]/page/about-me

Could someone help me with this problem?


Create .html pages - El Forum - 02-15-2014

[eluser]CroNiX[/eluser]
There's no real benefit to having an .html extension nowadays, but you can try setting the url_suffix setting in application/config/config.php


Create .html pages - El Forum - 02-15-2014

[eluser]CroNiX[/eluser]
Also, if you don't want 'page' in the url, your route would be:
Code:
$route['(:any)']   = 'page/index/$1';
and to load the homepage it would be
Code:
$route['default_controller'] = 'page'; //loads page/index for http://yoursite.com/



Create .html pages - El Forum - 02-16-2014

[eluser]Tpojka[/eluser]
[quote author="CroNiX" date="1392506123"]There's no real benefit to having an .html extension nowadays, but you can try setting the url_suffix setting in application/config/config.php[/quote]
recently, I had one situation that I needed to add that. In matter of fact On page was flash animated navigation header that client wanted to keep. Since I didn't have *.fla source but only *.swf with integrated links with html endings, converting site to CI, I made it with *.html suffix.
In other cases, I agree there is no point these days to keep it up.


Create .html pages - El Forum - 02-16-2014

[eluser]Unknown[/eluser]
[quote author="CroNiX" date="1392506869"]Also, if you don't want 'page' in the url, your route would be:
Code:
$route['(:any)']   = 'page/index/$1';
and to load the homepage it would be
Code:
$route['default_controller'] = 'page'; //loads page/index for http://yoursite.com/
[/quote]

Cheers, this worked for me.

I know it's not needed to use .html, but the person that i'm making his website for doesnt understand that and just want it in his website Smile


Create .html pages - El Forum - 02-18-2014

[eluser]Unknown[/eluser]
If .html will be of no use the how can we identify that it is an html file..??

<a href="http://webeminence.com/squarespace-review/">squarespace website builder</a>