Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

view a url variable in a view

I want to see who sent the url variable in the view using php

public function KardexAction($ART_CODIGO) {

}

Can you explain? Your question isn't clear.



36.3k

I get the variable url, this is generally used in the controller but I need to display that variable in the view


<?php
use Phalcon\Mvc\Model\Criteria;
use Phalcon\Paginator\Adapter\Model as Paginator;

class SpmArticuloController extends ControllerBase {
    public function KardexAction($ART_CODIGO) {
        $this->assets->addCss('css/datatables.min.css');
        $this->assets->addJs('css/datatables.min.js');

        $articulo=$this->base64url_decode($ART_CODIGO);
        $SPM_ARTICULO = SpmArticulo::findFirstByART_CODIGO($this->base64url_decode($ART_CODIGO));
        if (!$SPM_ARTICULO) {
            $this->flash->error("<div class='alert callout round' data-closable>"
                    . "<h5>Esto es Importante!</h5>"
                    . "<button class='close-button' aria-label='Dismiss alert' type='button' data-close>" . "<span aria-hidden='true'>&times;</span> </button>"
                    . "<p>El articulo no fue encontrado " . $this->base64url_decode($ART_CODIGO) . "</p></div>");

            return $this->dispatcher->forward(array(
                        "controller" => "spm_articulo",
                        "action" => "index"
            ));
        }
    }
}

It 's my view


<?php

?>

I want to see the variable $ ART_CODIGO in my view, in a variable php



1.7k
Accepted
answer
edited Nov '16

In controller:

$this->view->spm_articulo = $SPM_ARTICULO;

and in view:

echo $spm_articulo;

Documentation:

https://docs.phalconphp.com/en/3.0.0/reference/views.html#transfer-values-from-the-controller-to-views



36.3k

Thank you very much for your help