Need help get URI Segment

I using smarty for template renderer.

it is the views


<ul class="tabs">

        {section name="id" loop=$this->dataArray.menu}

            {if $this->currentAction == $this->dataArray.menu[id].action} // $this->currentAction is still null and need help to resolved

                <li><a href="{$this->dataArray.menu[id].url}" class="current"><span>{$this->dataArray.menu[id].label}</span></a></li>

            {else}

                <li><a href="{$this->dataArray.menu[id].url}"><span>{$this->dataArray.menu[id].label}</span></a></li>

            {/if}

        {/section}

</ul>



I want to diff between two of <LI>, if the menu (<li>) is clicked then change class to "current", and it will marking the current menu.

the problem is. how to know the URI segment example :

http://myblog.com/index.php?r=site/about&id=5

how to get "site/about&id=5"

of if I using pathURL. eg:

http://myblog.com/site/about/id/5

how to get "site/about/id/5"

I need help. please…

thanks before and after…

Did you try $_GET[‘ID’] ?

Oh ya… as you said. I have tried $_GET[‘ID’]. but there are no result.

so I trying add this method in CSmartyViewRenderer.php


        public static function getCurrentUrl(){

            $resUri = $newUri = $url   = array();

            $url[] = Yii::app()->controller->id;

            $url[] = Yii::app()->controller->action->id;

            $finalUrl = join('/',$url);

            $replacement = 'r='.$finalUrl;

            if (Yii::app()->urlManager->urlFormat == 'get'){

                $uri = explode('&',$_SERVER['QUERY_STRING']);

                foreach($uri as $v){

                    if($v != $replacement){

                        $newUri[] = $v;

                    }

                }


                if(count($newUri) > 0){

                    foreach($newUri as $kv){

                        $nn = explode('=',$kv);

                        $resUri[$nn[0]] = $nn[1];

                    }

                }

                return Yii::app()->urlManager->createUrl($finalUrl,$resUri);


            }else{

                return $_SERVER['REQUEST_URI'];

            }

        }

and works :slight_smile: Alhamdulillah…

thanks dimis283 for your attention :slight_smile:

Here is the solution , you can uri component use like this ; Yii::app()->uri->segment(2);

for details follow url

www.hasandemir.com/how-to-get-contoller-action-segments-like-codeigniter