in Yii classic you would do something like this:
Yii::app()->getModule('moduleName')->getBaseUrl();
but I'm not sure how you get the base url in Yii2
Should be
\Yii::$app->getModule('moduleName')->basePath;
Related
I have my i18n in a JSON file and I need to call a function from a piece of string.
I'll give you an example:
"give_me_feedback": "Do you need something else? <button onclick=\"sendFeedback()\">Send us your feedback</button>"
I call this message in my component, just like that:
<p [innerHTML]="'give_me_feedback | translate'"></p>
Usually, when I put a class or a button inside the i18n JSON file works fine, but, in this case, where I am calling a function specifically, it is not working.
Do you know if it is possible to do that from a JSON file? Or maybe I can put some kind of identifier and then call it from the component? I know that it could work in javascript, but I am not getting a good results in Angular. I' am using Angular 14.1.1
Thank you in advance!
I have an URL with UTM tags as below. When a user clicks/ hits the below URL(source), I would like to read UTM tags and redirect to another url(target).
Does anyone have a documentation link to read UTM tags and redirect the url in react?
Example:
Source
https://www.CustomDomain.com/?utm_source=linkedin&utm_medium=email&utm_campaign=sale&utm_id=123&utm_term=job&utm_content=ad
Target
https://www.CustomDomain.com/dashbord
With the latest react-router-dom *v6*, you can use a new hook named useSearchParams. Use it to get query params and you can then store them into localStorage,:
const [searchParams, setSearchParams] = useSearchParams();
searchParams.get("utm_source"); // similar for the rest of query params
With React router v4, You need to use this.props.location.search for generic or this.props.location (with useLocation) for functional components and parse the query parameters either by yourself or using a package
I am using JSON-server to create a mock backend. I want the url I use to fetch data to look like this: http://localhost:3000/org/org1/person/p1/configs.
My current .json file looks like this:
"org":[{"id":"org1"}],
"person":[{"id":"p1", "orgId":"org1"}],
"configs":[{"foo": "foo1","personId": "p1"}]
Right now when I try a GET request to the url specified with the above JSON structure I get a 404 error. I do not know why it is happening or how to fix it. Any help on how to solve the problem?
Thank you for your help
i.e, want to submit data to external url and after submitting data external url should open and . and from external url i will receive data
There are vary ways to do this. I'm not giving you code or example of that. Because you will get easily by search. I just give you ways to do that.
Solution 1:
You can store data in cookie and read cookie in any component.
Solution 2:
Make a service and in service make public variable. Import service in component and store data in variable. Now you can access that variable into other component.
Solution 3:
Use the angular feature of passing data between component's to components. Just do some R&D on that you will get easily required stuff to do that.
For more details with example read this link.
Hope it will help you...
I am using Django for making a website. I am using an HTML form with GET as the method.
The problem is that by default the get url is like this:
/search?name=user&place=place
But I want it to be something like:
my_site/search/user/place
How can that be done?
Why not use POST as method and retrieve the parameters in your view from request.POST? In this way they won't appear in your url.
Also, if you're expecting a list of results i recommend using ListView from views.generic, and in the dispatch() method you'll retrieve your parameters based on which you'll filter the user model (i guess).
It is better with a get request immo, but if you want something like: my_site/search/user/place it is easy, you just have to define the variables in your url and get the arguments in your function.
You can find more detail in django documentation
The only way you can do this in the browser is with Javascript. You will need to build the URL from the form contents. There are many mistakes you can make around encoding the values for the URL. You should be asking why you want to do it this way instead of using the QUERY_PARAMS as the form is doing.
Decoding it with Django isn't that hard, they are just variables in the URL pattern, but unless you have some kind of earth shattering new technology, you should let the browser send them to you without using JS to handcraft the URL.
Using the GET method send data via the web page. This means that the URL can be copied and rechecked at any time.