I want to got my current page URL using Yii 1.x.
This is my current page:
http://example.com/abc/def
and I want to got full URL or last parameters.
To get the current url you can do this.
Outside view files use this:
Yii::app()->controller->getId()
Yii::app()->controller->getAction()->getId()
Inside view files:
$this->getId()
$this->getAction()->getId()
Or simply:
Yii::app()->request->requestUri
Related
I want to fetch full URL path "http://127.0.0.1:8000/admin/2#document" using PHP or Laravel framework. I have tried to fetch using $_SERVER['REQUEST_URI'] but it did not work.
If I got your question right, you want to get the current URL of a page you are on? If that's the case, there's a url() helper method which outputs the current URL you're on. Inside your controller, do this:
$url = Request::url();
echo $url;
EDIT:
If you have some queries present in your logic, you can use getRequestUri() method:
$url = Request::getRequestUri();
echo $url;
You can read more in official documentation.
I have a Page in Cakephp that looks like
www.example.com/posts/next_posts
i.e. I have app/View/posts/next_posts.ctp
but I have Categories1, Categories2, Categories3,.... in Database.
How do I change the URL so that I assign a Variable of Database and it looks like
www.example.com/categories1/next_posts
www.example.com/categories2/next_posts
www.example.com/categories3/next_posts
By using the router. Read this chapter:
http://book.cakephp.org/3.0/en/development/routing.html
It will map a URL to a controller and action and passes arguments based on the URL. There are examples on that page as well if you're looking for that.
I am creating a realestate website, I want my url to be readable,
For example my site url is http://sitename/property/3, (3 represents property id)
I want to change it like this link
My question is how they are using "Residential-Apartment-Flat-in-Park-View-City-Gurgaon-4-BHK-for-Sale-spid-H13544257" this part in url.
Of course they are using id and all. How can I replace "property" with something like "residential-property-in-india" in my url and it should be changing dynamically according to search.
I hope it is clear what I want to do...
Everything is in the Yii guide
For example the folling urls config in the url manager component
array(
'posts'=>'post/list',
'post/<id:\d+>'=>'post/read',
'post/<year:\d{4}>/<title>'=>'post/read',
)
Will generate link like http://example.com/post/2004/My-title-that-can-be-long
You can tweak it to match your need,if I were you I'll read the Yii guide very carfully
At the last of rules array place this rule
'<page>'=>'someControlles/someAction',
And you will get in someControlles/someAction parameter. $page = 'any_text'. Another way to create your own UrlRule.
I have a url www.xy.de/glossar/anzeigen-programming
I want to use this url as www.xy.de/anzeigen-programming.
Last parameters are a variable. I want to show content after searching from database respect to last parameter.In urlmanager what have to do?
you can update your routes in config file.
Simply add something like this:
'glossar/<page:\w+>' => '/',
more info about routes could be found here
I know that you can use anchor_popup() to open up a new window in codeigniter, but what i cant figure out is how to pass values using that.
Here is the code i am using,
$attr = array('width'=>'800','height'=>'700');
echo anchor_popup('friends/'.$uid.'/'.$suid.'','add as friend',$attr);
Now i get a popup window which links to friends/34/34 where friends is a controller and rest are values which i want to give to my controller. but iam getting an error 404,
404 Page Not Found
The page you requested was not found.
I am using uri segment to grab the values.
Could any tell me what i am doing wrong?
the link friends/34/34/ is looking for a controller called "friends" and a method called "34", hence why it can't be found.
If your friends controller has no other methods, then change the link to this:
echo anchor_popup('friends/index/'.$uid.'/'.$suid,'add as friend',$attr);
else, add the appropriate method.