Dedy Khaidir
Dedy Khaidir

Reputation: 33

how to create dynamic content explicitly in the main views on CodeIgniter

I need help to accomplish a web page contains some existing html page. I need to load my new web page dynamically with many existing html page. And the existing is has an html format with each own assets folder. Thus, I use the CodeIgniter framework as my new main webpage.

My Web folder structure goes like this:

Project
|
|-->application
    |        
    |-->controllers
    |-->views
        |
        |-->main.php [Main index file]
        |-->Module01 [sub content (Dynamic) directory of main.php]
            |
            |-->ContentA [Section 1 of Module01]
                |
                |-->story_html5.html [I want to be sub content of main.php]
                |-->mobile [assets of story_html5.html]
                |-->story_content [resources of story_html5.html]
            |
            |-->ContentB [Section 2 of Module01]
                |

Web Structure Folder 1

Web Structure Folder 2

My main page (template) is main.php in the view directory. And I want to place the file story_html5.html as embedded content in the main.php dynamically. So, the content page can change dynamically as the user click any link on the main page. It can be switched into another story_html5.html inside another module, or ContentB directory. And the story_html5.html already has resources and assets on it's same location directory (sub directory) named mobile and story_content directory. It contains some js, CSS and flash files.

The question is, can I load dynamic content (with its resources) which is also reside on the view directory with CodeIgniter? Or is there any better way to accomplish this? I can do this without php / framework using object element like this:

<object type="text/html" data="Module01/ContentA/story_html5.html"></object>

But I need some security and some URL parameter rules, so I use php framework.

** I've already do dynamic page from the controller for my left menu, as referred from this page: load view within div tag using CodeIgniter

====== EDITED ======

I've thrown this variable from my controller like this:

$data['content'] = $this->load->view('Module01/ContentA/story_html5.html');

But the problem is, the page content (story_html5.html) does not load its content resource (js, css and flash files).

Upvotes: 1

Views: 723

Answers (1)

Dedy Khaidir
Dedy Khaidir

Reputation: 33

I finally able to solve this just by simply moving all of my modules directory outside of the application directoy. And then from my view side which is the main.php I can call the modules with an object element like this:

<object type = "text/html" data = "<?php echo base_url(); ?>Module01/ContentA/story_html5.html"></object>

So, I don't need to change any code for hundreds of files inside the html modules. It loaded the css and js and other resources, normally.

Upvotes: 1

Related Questions