Laravel URLs with query parameters - laravel

I want to implement a link in my application, but instead of it following this format:
/origin/{number}
I want it to look like this:
/origin=number
How do I implement a route successfully which will understand this link format? Surely Laravel is flexible enough to not only be able to parse slash-based URLs?

This should work:
Route::get('/origin={number}', ...);

Related

Getting the URL details - Laravel

I am working on a Laravel project, where I want to toggle partials based on the URL data like
foo.bar.com/#itemone/create
foo.bar.com/#itemone/view
Basically, I want to pass whether it is create or view to the partials like this
#include('partials.layouts._core_activity_header',['layout_type' => "create"])
How do I achieve this? Any help would be appreciated.
you can use the route name
Route::getCurrentRoute()->getName()
this will return the route alias

Can CodeIgniter route custom URLs?

I am trying to get pretty URLs on Codeigniter. Basically, here’s what I want.
//http://website.com/State/City/Neighborhood/Zip => http://website.com/search?lotsofParams=1234
$route['/State/City/Neighborhood/Zip'] = "search?location=blahblahblah&Submit=Search";
I am willing to write the routes manually, but right now that code isn’t working. Any idea how I can get this working?
no you are using QUERY STRINGS you can't route query string to friendly slashed urls.
You can re-write them with htaccess

way to pass variable through url in codeigniter

I got a big search module in my Codeigniter project. Well simply I am passing variable to a view like
<a href=<?php echo site_url('controller/view/1'); ?>>View List</a>
And fetching its data in controller like
$id=$this->uri->segment(3);
For pagination
http://wwww.site.com/controller/view/<filter id>/<page from>
This is working perfectly in the case of simple query.
Now I got some more filter quires like
Country
State
City
Customer type
etc etc
then the url should be
http://wwww.site.com/controller/view/1/id2/id3/i4/id5
Is this the correct way to do the process ? If not please give a little advice...
I am new to codeigniter
The problem you are facing i have recently found a solution for this.
When you are first sending parameters through url use POST instead.
When you get the parameters you can pass them to session in a variable
type. Next time when you paginate get the type value from session and
put it in your query to get the desired result.
If you have more than 1 parameters you can put them in sessions and
unset them on certain conditions so that they are not called in every query.
I think the best approach here is to create another method in the controller something like filtered_view that accepts a filter_id and a page number, and that methode will fetch the data from the database with the provided filter and you'll use your pagination class as usual.
Hope this help.

Route::get function like Kohana in CodeIgniter

Kohana have a smart routing system, I like feature when I can get url by route(Route::get('route_name',params), How implement this feature to codeigniter? Result that I need http://site.com/Sunglasses/Novus/202/ss14.05.html
Thanks
CodeIgniter doesn't support this feature (some would call it "reverse routing").
Maybe I'm not understanding the question properly as I haven't used Kohona, but if you just want to get the uri segment, you would use:
$this->uri->segment(3); //=202 in http://site.com/Sunglasses/Novus/202/ss14.05.html
To route a url with params you would use something like the following:
$route['products/(:any)/(:num)'] = "products/get_product/$1/$2";
so for example with this you could have a url of site.com/products/sunglasses/202 routing to the get_product() method of your products controller and then you would pick up the uri segment as above.

How to pass URL parameters to a joomla module

I have my own nice link http://www.link.com/sometext, now I would "enhance" this having the opportunity to write something like http://www.link.com/sometext?parameters=myParam cause I need to send a parameters to the article called by sometext.
Can I do something like that??? How can I pass parameters through the URL???? How can i get it's value?
Regards
You should use the standard Joomla way to retrieve GET/POST requests. This link should get you started:
http://docs.joomla.org/Retrieving_data_from_GET_and_POST_requests
$address = JRequest::getVar('address');
EDIT - just saw your other comment. To use PHP inside article, try something like Sourcerer: http://extensions.joomla.org/extensions/edition/custom-code-in-content/5051

Resources