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 8240071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:21:42+00:00 2026-06-07T20:21:42+00:00

I have a view module that has the html and the javascript for uploading

  • 0

I have a view module that has the html and the javascript for uploading files. I want the scripts to be loaded in the footer (just as an example). So basically the view file should be able to alter the contents of the footer or header. I am attempting to do this by reading the page first into buffer and then outputting the contents into the template file.

My controller has a function that looks like this –

public function test()
{
    ob_start();
    $this->load->view('content');  // uploader module
    ob_end_clean();
    $this->load->view('template', array($out1, $out2));  // ideally this will be output into a template file.  right now i'm just trying to echo it
}

My uploader module looks like this –

<div>some div for uploading</div>
<?php $out1 = ob_get_contents(); ?>
<?php ob_clean(); ?>

<script>
Logic for uploading that needs to go in the footer
</script>
<?php $out2 = ob_get_contents(); ?>
<?php ob_clean(); ?>

The template file would look like this –

<html>
<body>
<?php echo $out1; ?>

<scripts>other javascript code and includes</script>
<?php echo $out2; ?>
</body>
</html>

However I am unable to save the buffer contents and pass it back into the controller ($out1, $out2). Does anyone know how I can implement this? The goal is basically to delay-load javascript code but have the javascript code reside in the content files to make it easier to code. What’s the best way to do this? Do I need a global array or a new parent controller?

Thanks!

  • 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-06-07T20:21:45+00:00Added an answer on June 7, 2026 at 8:21 pm

    You can pass variables between views like so:

    <? ob_start(); ?>
    <script type="text/javascript">
      var foo = 66;
      console.log(foo + 16);
    </script>
    <? $this->load->var('my_script', ob_get_clean()) ?>
    

    If you run the above code in a view (or a controller, for that matter) ^^, the buffer’s contents will be available in any views which are loaded later as $my_script.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an express app that has a bunch of static javascript files that
Let's say i have 2 files located in the same folder. /Test/View.cshtml <h1>File that
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5
Very simple problem: I have a Public Sub (in a module) that I want
i am using the views 2 module. i have a view that gets a
I have a VB6 application that has a licensing module in VB6 which checks
I have a url http:// * .com/branch/module/view/id/1/cat/2/etc/3. It becomes. array ( 'module'=>'branch', 'controller'=>'module', 'action'=>'view'
I am beginner in rails. I have view that i try to print inside
I have a view containing a button. And i want to perform an action
So I have an application that has several modules (think of modules as different

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.