get value from one view & set it on element in another view in yii - variables

I have a view file called "user" .There it has a select tag called 'uid'.I will select a user id from the select tag and click on 'add' button.When I click 'add' button it will redirect to another view called 'projects' . There I have a select tag called 'userID' I want to set the value of this option to 'uid' which I have selected in 'user' view. How can I do this?
I don't want to pass the variable in url

I have never worked on PHP but you can try one of the following options:
You can pass that value in URL and access it on project view.
eg: /project/uid=1001
Use can store on client side using Local Storage or Session Storage.
http://www.gwtproject.org/doc/latest/DevGuideHtml5Storage.html
You can also use Route Parameters:
Use following link: http://www.yiiframework.com/doc/guide/1.1/en/topics.url
Hope this might

Related

Dot.NET Core Routing and Controller Processing discrepancy

I am trying to use the asp-route- to build a query string that I am using to query the database.
I am confused on how the asp-route- works because I do not know how to specifically use the route that I created in my cshtml page. For example:
If I use the old school href parameter approach, I can then, inside my controller, use the specified Query to get the parameter and query my database, like this:
If I use this href:
#ulsin.custName
then, in the controller, I can use this:
HttpContext.Request.Query["ID"]
The above approach works and I am able to work with the parameter. However, if I use the htmlHelper approach, such as:
<a asp-controller="Report" asp-action="Client" asp-route-id="#ulsin.ID">#ulsin.custName</a>
How do I get that ID from the Controller? The href approach does not seem to work in this case.
According to the Anchor Tag Helper documentation, if the requested route parameter (id in your case) is not found in the route, it is added as a query parameter. Therefore, the following final link will be generated: /Report/Client?id=something. Notice that the query parameter is lowercase.
When you now try to access it in the controller as HttpContext.Request.Query["ID"], since HttpContext.Request.Query is a collection, indexing it would be case-sensitive, and so "ID" will not get you the query parameter "id". Instead of trying to resolve this manually, you can use a feature of the framework known as model binding, which will allow you to automatically and case-insensitively get the value of a query parameter.
Here is an example controller action that uses model binding to get the value of the query parameter id:
// When you add the id parameter, the framework's model binding feature will automatically populate it with the value of the query parameter 'id'.
// You can then use this parameter inside the method.
public IActionResult Client(int id)

Set branch postback url parameter with track url parameter

I'm trying to add just one parameter to my postback url to a custom partner. What I need is to pass a Click Id that advertiser will put into link. For example hi'll make traffic to this link - cq8y2.app.link/?click_id=777 how could i map that click_id parameter to postback url?
You should use a macro to extract the click_id value. Append to the postback URL as a GET-parameter the following:
?clickid=${ (last_attributed_touch_data.~click_id)! }

How to add additional variables in yii url

I'm working with Yii framework and i'm trying to implement "create pdf" button on all sorts of different url's.
My first plan was to simply add variable to url where "create pdf" button links:
'url' => Yii::app()->request->getUrl().'&pdf=true',
And it works fine on all links except when i enter directly to site like: www.example.com. In that case there is no index.php in url so button link is unusable as it looks like this:
www.example.com/&pdf=true
Is there Yii way to append variables to url or I need to do manual checks?
create your links like this :
Yii::app()->createUrl('controllerName/actionName', array('number' => 2, 'name'=>'john'));
//or this if you want it with http:://
Yii::app()->createAbsoluteUrl('controllerName/actionName', array('number' => 2, 'name'=>'john'));
you can add your parameter(s) to the original parameters with the CMap::mergeArray($_GET, array('pdf' => 'true'))
and use the Yii::app()->createUrl or your Controller's createUrl function:
http://www.yiiframework.com/doc/api/1.1/CApplication#createUrl-detail
http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail

automatically pointing the id within the yii urlManager

or in other words get rid of the /id/ in the address bar.
I have the following specified in urlManager:
'<controller:\w+>/update/<sid:\w+>'=>'<controller>/<action>'
which means I need to specify the following in the url address bar:
mysite.com/post/update/sid/s390seret88se
How can I configure it so that all I need is:
mysite.com/post/update/s390seret88se
I don't want the sid to be visible in the address bar.
If you want hide sid only for update action do this
'<controller:\w+>/update/<sid:\w+>'=>'<controller>/update'
Or if you want to update for all actions use
'<controller:\w+>/<action:\w+>/<sid:\w+>'=>'<controller>/<action>'

Yii: CMenu items for different module

I'd like to make a menu in Layout which the items are linked to other different module.
e.g:
Item "Product" linked to an action in Product Module, item "Service" linked to an action in Service Module.
It won't work when I set the 'url'=>('product/<controllerID>/<actionID>') and 'url'=>('service/<controllerID>/<actionID>') because once we're in Product module and click the menu "Service", the URL become
index.php?r=product/service/<controllerID>/<actionID>
instead of
index.php?r=service/<controllerID>/<actionID>
and it will be 404 error. (for sure, because the Service Module isn't inside Product Module but the URL makes it looks like that).
Any solution for this?
Check the createUrl() documentation :
the URL route. This should be in the format of 'ControllerID/ActionID'. If the ControllerID is not present, the current controller ID will be prefixed to the route. If the route is empty, it is assumed to be the current action. If the controller belongs to a module, the module ID will be prefixed to the route. (If you do not want the module ID prefix, the route should start with a slash '/'.)
That last line tells us everything. Best thing to do for you is start all the routes with a / :
'url'=>array('/<moduleID>/<controllerID>/<actionID>')
Check this
'url'=>$this->createUrl('/<moduleId>/<controllerID>/<actionID>')