Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6926029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:51:57+00:00 2026-05-27T10:51:57+00:00

controller $data[controller] = $table; $data[rows] = $this->base_model->get();//get table attributes and names $write_add = $this->load->view(generate/add,$data,TRUE);//load

  • 0

controller

$data["controller"] = $table;
$data["rows"] = $this->base_model->get();//get table attributes and names
$write_add = $this->load->view("generate/add",$data,TRUE);//load file into var
$file_vadd = fopen($path["dirname"].'/generate/views/'.$data["controller"].'/add.php',"w+"); //write to file

generate/add.php (template)

<?php echo "<?php " ?>echo form_open('<?=$controller?>/add'); ?>
        <fieldset>
        <legend>New <?=$controller?></legend>
        <?php foreach($fields as $field): ?>
            <label for="<?php echo $field->name?>" ><?php echo $field->name?></label>
            <?php if(!empty($rel)) : ?>
                    <?php if($rel["rel_type"]==1 && $field->name == $rel["rel_fk"] ):?>
                        <select name="<?php echo $field->name?>" id="<?php echo $field->name?>">

                            <?php echo "<?php " ?> foreach($<?=$rel["rel_table"]?>_option as $<?=$rel["rel_table"]?>): ?>
                                <option value="<?php echo "<?php " ?>echo $<?=$rel["rel_table"]?>-><?=$rel["rel_pk"]?>; ?>" ><?php echo "<?php " ?>echo $<?=$rel["rel_table"]?>-><?=$rel["rel_view"]?> ;?></option>

                            <?php echo "<?php " ?> endforeach; ?>
                        </select>

                    <?php else: ?>
                        <input type="text"  name="<?php echo $field->name?>" id="<?php echo $field->name?>"  />
                <?php endif; ?>  
            <?php endif; ?>
        <?php endforeach;?>
        <input name="submit" type="submit"  value="Add"/> 
       </fieldset>   
    </form>

i have a controller which will call this template to create views, controllers and models. i dont know a better way to do this and i dont like putting the php tag inside a php tag. suggestion?

This is like “bake” function in cakephp. But im creating a codeigniter version of bake. the script is running. But my code is messy.? looking for better way to manage the template file..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T10:51:57+00:00Added an answer on May 27, 2026 at 10:51 am

    A simple way of doing this is enabling output buffering, including the php file (which lets it do its thing), end output buffering and saving the result in a file. Something along the lines of

    ob_start();
    include("foobar.php");
    $temp .= ob_get_clean();
    file_put_contents('foo.tpl', $temp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having created my model, view and controller in an attempt to get data from
I want to access the value of a view controller data member variables in
In previous releases there were 3 ways to pass data from controller to view
I'm passing data between my controller and my view using a ViewModel class. When
How can in controller redirect with post same data like this do form <form
I have a view controller that gets presented modally and changes some data that
With the following code, I send data to a view controller, which then retrieves
Basically I have this In my Asp.net controller public ActionResult RenderMyView() { data =
I'm having a problem with UITableView, populated via Core Data. The table view is
I have a question with respect to putting JSON data into a table view.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.