Welcome Guest, Not a member yet? Register   Sign In
What causes this “Missing argument 2 for Categories::posts()” error?
#1

I am working on a small blogging application. There is a clear separation between its back-end and its front-end.
The back-end is an [b]API[/b], made with Codeigniter 3, that spits out pages, posts, pagination etc.


In this API, the [b]Categories[/b] controller displays, among others, [i]post by category[/i]:



Code:
public function posts($path, $category_id) {
    //load and configure pagination
    $this->load->library('pagination');
    $config['base_url'] = "http://".$_SERVER['HTTP_HOST'] . $path;
    $config['base_url'] = base_url('/categories/posts/' . $category_id);
    $config['query_string_segment'] = 'page';
    $config['total_rows'] = $this->Posts_model->get_num_rows_by_category($category_id);
    $config['per_page'] = 12;

    if (!isset($_GET[$config['query_string_segment']]) || $_GET[$config['query_string_segment']] < 1) {
        $_GET[$config['query_string_segment']] = 1;
    }

    $limit = $config['per_page'];
    $offset = ($this->input->get($config['query_string_segment']) - 1) * $limit;
    $this->pagination->initialize($config);

    $data = $this->Static_model->get_static_data();
    $data['pagination'] = $this->pagination->create_links();
    $data['pages'] = $this->Pages_model->get_pages();
    $data['categories'] = $this->Categories_model->get_categories();
    $data['category_name'] = $this->Categories_model->get_category($category_id)->name;
    $data['posts'] = $this->Posts_model->get_posts_by_category($category_id, $limit, $offset);

    // All posts in a CATEGORY
    $this->output->set_content_type('application/json')->set_output(json_encode($data,JSON_PRETTY_PRINT));
}

The code above has a bug who's cause I can not find. The error message the application throws is:

Code:
Missing argument 2 for Categories::posts()

Where is my mistake?
Reply


Messages In This Thread
What causes this “Missing argument 2 for Categories::posts()” error? - by Ajax30 - 10-06-2019, 04:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB