How to add #ancora at the end of the URL (with codeigniter paging)

Asked

Viewed 262 times

1

How do I add the anchor id at the end of the url?

at this time my url is the following: http://localhost/php_focas/index.php? per_page=3

I needed it to be this way: http://localhost/php_focas/index.php? per_page=3#agenda

I have the following controller:

.
.
.

$urlPaginacao = site_url();

    //PAGINAÇÃO *****

    $get_total_results = $this->admin_model->mostrarAgenda();
    $totalResultados = $get_total_results['total'];
    $getPaginacao = $this->paginacao($urlPaginacao,$totalResultados, 3);

    $getEventos = $this->admin_model->mostrarAgenda($getPaginacao['inicio'], $getPaginacao['quantidadeResultados']);

    $data['district'] = $this->admin_model->mostrarDistrict();
    $data['local'] = $this->admin_model->mostrarLocal();
    $data['life'] = $this->admin_model->mostrarLife();
    $data['useful'] = $this->admin_model->mostrarUseful();
    $data['agenda'] = $getEventos['dadosGerais']; //dados gerais do model
    $data['pag'] = $getPaginacao['paginacao'];




    $this->load->view('index', $data);

}

public function paginacao($urlPaginacao, $totalResultados, $resultadosPorPagina = 3){

$config['base_url'] = $urlPaginacao;
$config['total_rows'] = $totalResultados;
$config['per_page'] = $resultadosPorPagina;
$config['page_query_string'] = TRUE;

$config['full_tag_open'] = "<ul class='pagination pagination-sm'>";
$config['full_tag_close'] ="</ul>";
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$config['cur_tag_open'] = "<li class='active disable'><a>";
$config['cur_tag_close'] = "</a></li>";
$config['next_tag_open'] = "<li>";
$config['next_tagl_close'] = "</li>";
$config['prev_tag_open'] = "<li>";
$config['prev_tagl_close'] = "</li>";
$config['first_tag_open'] = "<li>";
$config['first_tagl_close'] = "</li>";
$config['last_tag_open'] = "<li>";
$config['last_tagl_close'] = "</li>";

$config['first_link'] = TRUE;
$config['last_link'] = TRUE;

$quantidade = $resultadosPorPagina;
$this->pagination->initialize($config);

$data['quantidadeResultados'] = $quantidade;
$data['inicio'] = $this->input->get('per_page') != NULL ? $this->input->get('per_page') : '0';
$data['paginacao'] = $this->pagination->create_links();
return $data;

}

and I have the following model:

public function mostrarAgenda($inicio=NULL, $quantidade=NULL){

    $inicio = $inicio != NULL ? "LIMIT {$inicio},{$quantidade}" : "";

    $sqlGeral = "SELECT * FROM tblagenda {$inicio}";

    $queryGeral = $this->db->query($sqlGeral);
    $data['inicio'] = $inicio;
    $data['total'] = $queryGeral->num_rows();
    $data['dadosGerais'] = $queryGeral->result();

    return $data;
}

I am unable to enter the #schedule at the end of the url

Thank you

1 answer

0


I found the solution that was right in front of my eyes,

in my controller in the paging function, in the paging configs just add the following config:

$config['suffix'] = '#agenda';

DONE

Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.