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

  • Home
  • SEARCH
  • 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 8579785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:41:05+00:00 2026-06-11T20:41:05+00:00

For an action in my controller that needs no view, I’m disabling the layout

  • 0

For an action in my controller that needs no view, I’m disabling the layout and template like this:

$this->autoRender = false;

And it’s all good. However, in that same action I’m echoing a ‘pass’ or ‘fail’ to signal my view of the result. The problem is a bunch of text is also echoed: (my ‘fail’ or ‘pass’ at the very end)

 <!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
</head>
<body>
        </body>
</html>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head> ....

This is echoed 8 o 9 times.

How can I get rid of that so only my ‘pass’ or ‘fail’ are echoed?
Can you help?

I’ve tried

$this->layout = false; and
$this->render(false);

Thank you so much.

Update:**
Just noted it also echoes a bunch of javascrip code out of nowhere, (Removed < for pasting here) e.g.: pre class=”cake-error” a href=”javascript:void(0);” onclick=”document.getElementById(‘cakeErr5035af14add0c-trace’).style.display = (document.getElemen..

This is the whole action **

//This action is called via:
//mysite/qcas/loadProdFromFile/dirId:76
// or
//mysite/qcas/loadProdFromFile/dirId:76/filePath:J:\ep12219 - Air Pollution\Load\prodValues.csv


function loadProdFromFile() {
    $this->autoRender = false;

    // here we get dir info based on first (and perhaps sole) param received: dirId
    $dirName = $this->Qca->Dir->find('first', array(
        'recursive' => 0,
        'fields' => array('Dir.name'),
        'conditions' => array('Dir.id' => $this->request->params['named']['dirId']),
            )
    );

    //if used did not provide filePath param, we use a default location based on dir info
    if ((is_null($this->request->params['named']['filePath']))) {
        $basedir = '/disk/main/jobs/';
        $dirs = scandir($basedir);

        $found = 0;
        foreach ($dirs as $key => $value) {
            if (strpos($value, $dirName['Dir']['name']) > -1) {
                $found = 1;
                break;
            }
        }
        if (!$found) {
            echo 'failfile';
            exit;
        }
        $loadDir = '/disk/main/jobs/' . $value . '/Load/';
        $thefiles = glob($loadDir . "*.csv");
        $prodFile = $thefiles[0];
    } else {
        // if user provided a path, we build a unix path
        // for some reason the extension is not posted, so we append it: only csv can be processed anyways
        $prodFile = AppController::BuildDirsFile($this->request->params['named']['filePath']) . ".csv";
    }

    // we get here with a working file path
    $fileHandle = fopen($prodFile, 'r');

    if ($fileHandle) {
        // start processing file to build $prodata array for saving to db
        $counter = 0;
        while (!feof($fileHandle)) {
            $line = fgets($fileHandle);
            if (strlen($line) == 0) {
                break;
            }

            $values = explode(',', $line);
            $prodata[$counter]['dir_id'] = $this->request->params['named']['dirId'];
            $prodata[$counter]['name'] = $dirName['Dir']['name'];
            $prodata[$counter]['employee_id'] = $values[1];

            $a = strptime($values[0], '%m/%d/%Y');
            $timestamp = mktime(0, 0, 0, $a['tm_mon'] + 1, $a['tm_mday'], $a['tm_year'] + 1900);
            $prodata[$counter]['qca_start'] = $timestamp;

            $end = $timestamp + ($values[2] * 60);
            $prodata[$counter]['qca_end'] = $end;

            $prodata[$counter]['qca_tipcode'] = $values[3] * -1;

            $prodata[$counter]['qca_durint'] = 0;
            $prodata[$counter]['qca_durtel '] = 0;
            $prodata[$counter]['qca_durend'] = 0;
            $prodata[$counter]['qca_signal'] = 0;
            $prodata[$counter]['qca_restart'] = 0;
            $prodata[$counter]['qca_stop'] = 0;
            $prodata[$counter]['qca_prevtipc'] = 0;
            $prodata[$counter]['qca_respid'] = 0;
            $prodata[$counter]['qca_lastq'] = 0;
            $prodata[$counter]['qca_smskey'] = 0;
            $prodata[$counter]['qca_telconta'] = 0;
            $prodata[$counter]['qca_execuqoc'] = 0;
            $counter++;
        }
    } else {
        // file was just no good
        echo 'fail';
        exit;
    }
    if (count($prodata) > 0) {
        $this->Qca->saveMany($prodata);
        echo count($prodata);
    }
}
  • 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-11T20:41:07+00:00Added an answer on June 11, 2026 at 8:41 pm

    First of all I will paste here a fragment from cakeapi under http://api.cakephp.org/class/controller about how autoRender works:

    autoRender boolean
    Set to true to automatically render the view after action logic.

    So this:

     $this->autoRender = false ;
    

    will generally turns off rendering the view but just after action logic is done. So thats why you get the echos from your action logic. You can whether remove your echo’s from your code to prevent showing them or try this schema,

    if something is wrong:

    $this->Session->setFlash('Error');
    $this->redirect(array('action' => 'your_error_page'));
    

    which will move you to ur error page with Error string as a Flash text, or when its all fine:

    $this->Session->setFlash('Its fine dude!');
    $this->redirect(array('action' => 'your_ok_page'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As explained in this question , I have a view controller that needs to
I have a controller action that checks this.User.Identity.IsAuthenticated What do you suggest how to
If i have a controller action Create that returns a view with the following
I'd like to have an Index action for a Users controller that takes an
I have a main view and the URL for this view has a Action/Controller/Area
I have a controller method in ASP.NET MVC that looks like this: public ActionResult
Currently, I have a Controller with an Index() action method that needs authorization: public
I have a controller action that builds a pdf and than downloads it by
If i have a Controller Action that may recieve both HTTP GET and HTTP
I have a new action in my controller that I'm passing parameters into so

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.