Welcome Guest, Not a member yet? Register   Sign In
Basic CMS for CodeIgniter applications
#1

[eluser]goldpelican[/eluser]
Currently developing a website in CodeIgniter that's primarily CRUD/reporting in nature, but will end up with a number of "static" pages such as Privacy, About Us, Locations etc. My current understanding is that the easiest way to manage these pages is to create views containing the content, and call these views from the controller when someone clicks on the relevant link, but maintenance would mean updating a PHP file inside of the view folder, which isn't friendly to non-technical users. So I hit upon the idea of using a basic CMS to manage "wordy" HTML content, and modifying the controller to pass a block of HTML as data to a view, with the HTML being pulled from a CMS. Using a CMS will allow a business user to update information like the privacy policy, office locations etc without having to necessarily touch code. Adding additional pages to the website however would involve coding as the controller at minimum would need to be updated, but that's not such an issue.

Is this overcooking the solution given that I could alternatively simply use a php include() inside of a generic view to pull in nominated HTML files that could be managed in a WYSIWYG editor?

What approaches do other people use for managing static content like this that might need to be maintained by a non-technical user?
#2

[eluser]Ben Edmunds[/eluser]
I've used many different ways to accomplish this. Usually depending on the clients preference.

If you want to use a full CMS though I can definitely recommend PyroCMS and IonizeCMS.
#3

[eluser]goldpelican[/eluser]
I think for now (technically I'm the client, but I want to use a best practice approach for future use) I will use a generic "static content wrapper" view, and pass a path to a specific HTML file as an element in the data array that gets passed to the view when loaded. Then I can use a regular php include() statement to include the source of the nominated HTML file into the relevant placeholder of the view.

I use an overall generic default view for my website, and load header, menu, footer and content views into the default view to assemble a page - so I can use a static content wrapper view for HTML, and load it into the "content" section of my default view. I'll just maintain the HTML content using an editor for now that (should it be necessary in future) can be edited using a WYSIWYG tool.

Will have a think about where I want to host the HTML... it's technically data, not a view, so under the view folder may not be appropriate. This also means that HTML nuff nuffs in future won't need to touch files inside of the application structure, potentially creating issues.
#4

[eluser]Berik[/eluser]
you could have a "page" method within your controller that loads a template view and pass the inner html file as an argument to the method.

for example

-------------------------------------------------

(in controllerName):

function page($html_file_to_load)
{
...
check to see if file exists on server, if not show 404 page or redirect to homepage

// if the contents are outside the app directory
$the_contents = file_get_contents($html_file_to_load);

// if the contents are in the view directory
$the_contents = $html_file_to_load;

$data['html_content'] = $the_contents;
$this->load->view('pages_template', $data);
}

-------------------------------------------------

(in application/views/pages_template.php):

header stuff (doctype and other stuff)
site header html
<?php echo $html_content; ?>
site footer html

-------------------------------------------------

(in application/config/routes.php for nicer urls):

$route['(:any)'] = "controllerName/page/$1";
#5

[eluser]Référencement Google[/eluser]
Nahhh, are you mad to recommend such code by passing a parameter in the url to get a file content ? That^s terrible recommendation, totally insecure and dangerous !
#6

[eluser]gRoberts[/eluser]
I have made a number of CMS based sites on CI, infact every site I have made uses CI in this manner.

I simply have three tables.

Content
Page
PageTemplate

The page table contains a path, i.e. 'path/to/page' which using a MY_Router file, I check to see whether the current segments match this path. If so, I redirect the request a controller that passes across the PageID.

That page then has a template associated which determines which View to use. Within that view, it access data from the Content table based on the current PageID.

All in all, you can then use a CMS to edit the content easily.
#7

[eluser]Référencement Google[/eluser]
The problem Berik is not related to CI but to what you are recommending to the world, means you are telling people they can pass a parameter in the url and get a file content from this, without any check of your system and relaying on the fact CI is secure.

Do you know there are many newbies not learning PHP from scratch anymore but learning CI directly and claim they know to code in PHP? That is where your recommendation is a huge security problem, what if they make the same without CI and make your code without a framework? And what if CI is misconfigured by the user and allow some bad chars in the url?
#8

[eluser]gRoberts[/eluser]
In my case, that wouldn't happen. Only routes defined in the DB that are matched to a PageID work. Even then I am only loading Views that CI would normally load via a controller.
#9

[eluser]Référencement Google[/eluser]
Yap gRoberts, that is a sure way to be secure instead of Berik recommendation to pass directly an url parameter to a file ! Dangerous recommendation which made me jump of my chair...




Theme © iAndrew 2016 - Forum software by © MyBB