List BLOG and show on the same page the ARTICLE chosen

0

I'm working with PHP and I use friendly URL. When you click the <a class="nav-link" href="<?php echo URL::getBase(); ?>blog" tabindex="12">blog</a> link, my URL is:

  

link

Opening the page blog.php it contains the function getBlog() function that lists all articles, with a pagination of 10 per page.

By clicking on one of these articles, my URL is:

  

link

Opening the page artigo.php this contains the function:

function getViewBlog() {  
    // Ler URL (array)  
    $url = $_SERVER['REQUEST_URI'];  
    $valor = explode("/", $url);  
    // Recebe o id do rgf_content via GET  
    $id_blog = $valor[3];
    ...
}

Where to get the id_blog of the URL and show the full content of this article on this page.

What I'm trying to accomplish is to make these two functions open on the same page as here in this case would be blog.php .

  

HOME > ROGARFIL.COM.BR > ARTICLE > 63 > TI > MY COMPANY NEEDS A WEBSITE

The reason that leads me to this logic is that the way it is and when I am on the page artigo.php and clicking on the breadcrumbs link in article the error appears:

  

Notice: Undefined offset: 3 in C: \ xampp \ htdocs \ rogarfil.com.br \ src \ includes \ files \ functions.php on line 326

Because the URL of the $id_blog variable does not appear in the URL.

    
asked by anonymous 02.07.2018 / 19:34

1 answer

-1

The blog page stayed like this and resolved:

// Read URL (array)
$ url = $ _SERVER ['REQUEST_URI'];
$ value = explode ("/", $ url);

if (isset ($ value [3])) {

<!-- Blog Grid --> <section id="portfolio"> <div class="container"> <div class="row"> <div class="col-lg-12 mt-3"> <?php getViewBlog();?> </div> </div> </div> </section><!-- /.Blog Grid -->

} else {

<!-- Blog Grid --> <section id="portfolio"> <div class="container"> <div class="row"> <div class="col-lg-12 mt-3"> <h1 class="display-5 text-uppercase"><i class="fa fa-newspaper-o text-info" aria-hidden="true"></i>&nbsp;blog&nbsp;</h1> <p class="lead text-info text-uppercase" >artigo&nbsp;sobre&nbsp;ti,&nbsp;programa&ccedil;&atilde;o,&nbsp;cria&ccedil;&atilde;o&nbsp;&&nbsp;acad&ecirc;micos</p> <hr class="linha" /> <?php getBlog();?> </div> </div> </div> </section><!-- /.Blog Grid -->
}

    
06.07.2018 / 19:06