List BLOG and show on the same page the chosen ARTICLE

Asked

Viewed 61 times

0

I am working with PHP and use friendly URL. By clicking on the link <a class="nav-link" href="<?php echo URL::getBase(); ?>blog" tabindex="12">blog</a>, my URL gets:

http://127.0.0.1/rogarfil.com.br/blog

Opening the page blog.php this contains the function function getBlog() listing all articles with a 10 page page page page.

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

http://127.0.0.1/rogarfil.com.br/artigo/63/ti/minha-empresa-precisa-de-website

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 does the id_blog of the URL and shows all the contents of this article on this page.

What I am seeking to accomplish is to have these two functions open on the same page as here in this case would be the blog.php.

HOME > ROGARFIL.COM.EN > ARTICLE > 63 > IT > MY COMPANY NEEDS WEBSITE

The reason I come to this logic is that the way it is and when I’m on the page artigo.php and when clicking on the link of the article Readcrumbs appears the error:

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

Because the URL does not show the contents of the variable $id_blog.

1 answer

-1

The blog page stayed this way and solved:

// 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 -->
}

  • just use the isset on the conditional if

Browser other questions tagged

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