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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:22:34+00:00 2026-06-15T04:22:34+00:00

im having troubles with a web app that a teacher ask me to modify,

  • 0

im having troubles with a web app that a teacher ask me to modify, the problem its that i dont know about cakePHP and i have been having troubles.After reading a lot, i think i have grasped the basics of the framework. My problem now its that i have a link in a view so i call a function in the controller to retrive data from the model, the problem its that each time i try to acces the function , the app makes me log in, and the idea its that it shouldnt.
I dont know exactly how the session handling on cakePhp works so, im requesting some help.
the code for the controller its this:

<?php
class RwController extends AppController {
var $name = 'Rw';
// var $paginate = array(
    // 'Tip' => array(
        // 'limit' => 1,
        // 'order' => array(
            // 'tip.created' => 'desc'
        // ),
    // ),
    // 'Evento' => array(
        // 'limit' => 1,
        // 'order' => array(
            // 'evento.fecha' => 'desc'
        // ),
    // )
// );
function map() {
    $this->helpers[]='GoogleMapV3';
}
function pageForPagination($model) {
    $page = 1;
    // $chars = preg_split('/model:/', $this->params['url']['url'], -1, PREG_SPLIT_OFFSET_CAPTURE);
    // #print_r($chars);
    // if(sizeof($chars) > 1 && sizeof($chars) < 3) {
        // #echo "Belongs to ".$model.": \n";
        // #echo var_dump($chars);
    // }
    // $params = Dispatcher::parseParams(Dispatcher::uri());
    // echo "<p>".var_dump($params)."</p><br />";
    #echo $this->params['named']['model'].$model;
    #echo $this->params['named']['page'];
    $sameModel = isset($this->params['named']['model']) && $this->params['named']['model'] == $model;
    $pageInUrl = isset($this->params['named']['page']);
    if ($sameModel && $pageInUrl) {
        $page = $this->params['named']['page'];
    } else {
        #echo var_dump($this->passedArgs);
    }
    $this->passedArgs['page'] = $page;
    return $page;
}

function index() {
    $this->log('indexeando esta chingadera','debug');
    $this->loadModel('User');
    $this->loadModel('Evento');
    $this->loadModel('Tip');

    $dataEvento = $this->Evento->find('all');
    $dataTip = $this->Tip->find('all');

    $page = $this->pageForPagination('Evento');
    $this->paginate['Evento'] = array(
        'contain' => false,
        'order' => array('Evento.fecha' => 'desc'),
        'limit' => 1,
        'page' => $page
    );
    $dataEvento = $this->paginate('Evento');

    $page = $this->pageForPagination('Tip');
    $this->paginate['Tip'] = array(
        'contain' => false,
        'order' => array('Tip.created' => 'desc'),
        'limit' => 1,
        'page' => $page
    );
    $dataTip = $this->paginate('Tip');

    $this->set('users', $this->User->find('all'));
    $this->set('eventos', $dataEvento);
    $this->set('tips', $dataTip);
    $this->set('rw');

    if(isset($this->params['named']['model'])) {
        if (strcmp($this->params['named']['model'], 'Evento') == 0) {
            if($this->RequestHandler->isAjax()) {
                $this->render('/elements/ajax_rw_evento_paginate');
                return;
            }
        } elseif (strcmp($this->params['named']['model'], 'Tip') == 0) {
            if($this->RequestHandler->isAjax()) {
                $this->render('/elements/ajax_rw_tip_paginate');
                return;
            }
        }
    }
}

function about($id = null) {
    $this->Rw->recursive = 0;
    $this->set('rw', $this->paginate());
}

function beforeFilter() {
        parent::beforeFilter(); 
        $this->Auth->allow(array('index', 'about'));
}

function getCentros($id){
    $this->loadModel('Centro');
    $this->log('getcentros','debug');
    if( sizeof($id) > 1){
        $this->set('centros', $this->Centro->query("SELECT centros.id, name, latitud ,longitud 
                                                        FROM `centros`,`centrosmateriales` 
                                                            WHERE centros.id = centro_id 
                                                                AND material_id ='".$id[0]."' 
                                                                    OR material_id='".$id[1]."'"));
    }elseif( sizeof($id) >0) {
        if($id == 0){
            $this->set('centros', $this->Centro->find('all'));
        }else{
            $this->set('centros', $this->Centro->query("SELECT centros.id, name, latitud ,longitud 
                                                            FROM `centros`,`centrosmateriales` 
                                                                WHERE centros.id = centro_id 
                                                                    AND material_id ='".$id[0]."'"));
            }
        }
        $this->redirect(array('action' => 'index'));
}


}   
?>

Edit:

The function im calling is getCentros().

this is what i have in app_controller.

<?php 
class AppController extends Controller {
    var $components = array('Session', 'Auth', 'RequestHandler');
    var $helpers = array('Html', 'Form', 'Time', 'Session', 'Js', 'Paginator', 'GoogleMapV3');
    function beforeFilter() {
        $this->Auth->userModel = 'User';
        $this->Auth->fields = array('username' => 'email', 'password' => 'password');
        $this->Auth->loginAction = array('admin' => false, 'controller' => 'users', 'action' => 'login');
        $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'index');
    }
}
?> 
  • 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-15T04:22:36+00:00Added an answer on June 15, 2026 at 4:22 am

    try this

    $this->Auth->allow(array('*'));
    

    it allows you to access all functions inside the controller.

    But before that make sure that you have access on the controller with out errors because your controller name is like this

    class RwController extends AppController {
    
    }
    

    may be it want like this

    class RwsController extends AppController {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble when one of the jars that my web app depends on
i'm doing a web app for iPhone, i'm having some troubles with borders. To
I am having trouble finding how to create a simple web-app to analyse its
I have a web app that I want to use Backbone.js for. I have
i have a function in a php web app that needs to get periodically
I am having trouble encrypting a connection string in app.config. I have code that
I'm having troubles debugging a POST request I'm making from my web server to
I'm having trouble with Web Start. There is no problem if I start the
I'm having trouble with my Apache Web Server. I have a folder (htdocs\images) where
I'm having trouble finding/getting any logging output from a web service. I have a

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.