We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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.



81.2k

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



3.5k
Accepted
answer
edited Nov '16

In controller:

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

and in view:

echo $spm_articulo;

Documentation:

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



81.2k

Thank you very much for your help