Страница 404 не найдена при попытке передать значение в URL в Codeighter - PullRequest
2 голосов
/ 29 января 2020

Я пытаюсь передать значение в URL

http://192.168.1.136/dashboard/Projects/CodeIgniter-3.1.11/index.php/calls/call_id

И на странице 404 не найдена ошибка.

Я хочу передать call_id контроллеру. Скажите, пожалуйста, что я делаю неправильно.

Это контроллер

  class Calls extends CI_Controller {

    // I WANT TO ACCESS call_id HERE
    function __construct() {
      parent::__construct();
    }

    public function index($abc) {

      $this->load->helper('url');
      $call =  $this->uri->segment(3);
      $data = array('call_id' => $call, 'bar' => 'world');
      $this->load->view('Pages/MyAjax.php', $data);
    }
  }

Это конфигурация маршрутизатора

defined('BASEPATH') OR exit('No direct script access allowed');
$route['default_controller'] = 'welcome';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

Это конфигурация. php

defined('BASEPATH') OR exit('No direct script access allowed');
$config['base_url'] = '';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'MY_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['allow_get_array'] = TRUE;
$config['log_threshold'] = 0;
$config['log_path'] = '';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:i:s';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['encryption_key'] = '';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix']    = '';
$config['cookie_domain']    = '';
$config['cookie_path']      = '/';
$config['cookie_secure']    = FALSE;
$config['cookie_httponly']  = FALSE;
$config['standardize_newlines'] = FALSE;
$config['global_xss_filtering'] = FALSE;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';

Я хочу получить доступ к call_id в controller.

1 Ответ

2 голосов
/ 29 января 2020

Добавьте параметры к index() вот так index($call_id = NULL)

контроллер

  class Calls extends CI_Controller {

    function __construct() {
      parent::__construct();
    }

    public function index($call_id = NULL) {

      // $this->load->helper('url');
      // $call =  $this->uri->segment(3);
      $data = array('call_id' => $call_id, 'bar' => 'world');
      $this->load->view('Pages/MyAjax.php', $data);
    }
  }

и URL

http://192.168.1.136/dashboard/Projects/CodeIgniter-3.1.11/index.php/calls/index/30

, где последний сегмент выше URL 30 это call_id

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...