Question

In fuelphp, we can render template from controller. But I want prevent render template from package.

Example:

Step 1: fuelphp run controlelr -> render template

Step 2: run package -> have a command to clear all data in step 1. and render blank page.

Result with a blank page

$this->template->content = ...
\Package::removeTemplate();

I tried with

\Event::forge(array('shutdown'));
\Fuel::finish();

But it is not success. How can I do it?

Was it helpful?

Solution 2

I found a solution. Rewrite \Fuel::finish()

public static function finishS()
    {
        if (\Config::get('caching', false))
        {
            \Finder::instance()->write_cache('FuelFileFinder');
        }

        if (static::$profiling and ! static::$is_cli)
        {
            // Grab the output buffer and flush it, we will rebuffer later
            $output = ob_get_clean();

            $headers = headers_list();
            $show = true;

            foreach ($headers as $header)
            {
                if (stripos($header, 'content-type') === 0 and stripos($header, 'text/html') === false)
                {
                    $show = false;
                }
            }

            if ($show)
            {
                \Profiler::mark('End of Fuel Execution');
                if (preg_match("|</body>.*?</html>|is", $output))
                {
                    $output  = preg_replace("|</body>.*?</html>|is", '', $output);
                    $output .= \Profiler::output();
                    $output .= '</body></html>';
                }
                else
                {
                    $output .= \Profiler::output();
                }
            }
            // Restart the output buffer and send the new output
            ob_start();
            **/// Remove this line echo $output;**
        }
    }

OTHER TIPS

You can always modify your template, inside the controller in every function just use

$this->template

Example

class Controller_lorem extends Controller_Main {

   public $template = 'template_default';

   public function action_ipsum()
   {

       //use customize template other than default
       $this->template = View::forge('template_custom');

   }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top