How to call a customly created url in magento - magento

I have added one field in backend for adding url for Faq Post and successfully saved to the database.But I`m not sure how to call it back the url to display that particular post.My requirement is to generate a url for each faq categories post and have separate link to access them.
For example .If my faq category is Test and particular post in that category is test123.I want to generate link to access test123 something similar to {mywebsite}/faq/{faq_category}/{faq_post}.Please help me.

You need to Use "Url rewrite Management" when you save url in magento then also save url in url rewrite.
You need to save in url table following fields:
id_path = "faq/{faq_category_id}/{faq_post_id}"
request path ="faq/{faq_category}/{faq_post}"
target path = "faq/index/view/cat/{faq_category_id}/post/{faq_post_id}"
you need to create controller View action in indexController of your module.
you can get parameter like this :
$category_id = $this->getRequest()->getParam('cat');
$post_id = $this->getRequest()->getParam('post');
now run url {mywebsite}/faq/{faq_category}/{faq_post}

Related

How to custom API URL on codeigniter

I have a PHP CodeIgniter Controller with name index and have a method that get details of id kode ($kode) using API get method.
Now when i need to show kode data for example for id AALI
I call this URL
http://www.example.com/?q=AALI
My target
How to make user data accessible by next URLs
http://www.example.com/AALI
I've try using function _remap on code Igniter, but it still wont work.
Have a look at Codeigniter URLs
As per your statement, your controller name is index and there would be an index function in your controller which renders the default view. it means you have changed default_controller to index in your Config.php
Now if you read the link above about Codeigniter URLs, there is a way to get data which passed in the URL after "/" You have to load url helper you can either autoload(recommended) it or load it in your constructor or Controller as per your convenience
Then you can just type
$param=$this->uri->segment(2); // in case your URL is http://www.example.com/AALI
The first segment is controller itself, The second is the function if your url is complete and the third is the parameter in CI URL structure but if you are not providing function name the first segment will always be your controller . So the second is your parameter. Just save it in a variable and do what you like.

Create an SEO friendly url in Codeigniter

I have a scenario to create an SEO friendly URL in Code-igniter.
http://example.com/en/motors/used-car-for-sale/audi?sub_categories3=36
I want to create an SEO friendly url and remove the portion ?sub_categories3=36 from the url. The subcategory id 36 will be the 'A4'(Audi A4 car model).
So the url should be http://example.com/en/motors/used-car-for-sale/audi/a4 .
The sub_categories3 will be the id of each type under main category.
How can i do it?I found lot of articles to it.Please suggest me a best way to find it.
Pass all /motors requests to the correct controller with ('motors/(:any)') = 'myController/myFunction';
Get the second part of the url and pass it to a model that requests an article with that URL. Use the 'URL' helper for this.
Return data back to the controller and to your view.

a url that calls products but couldn't located how it's calling products of a catgory

The default feature according to my understanding for a
Url : http://example.net/index.php/products/refrigeration.html
Path i will look into is : Backend > catalog > url rewrite Management > then search for products/refrigeration.html in Request path field.
This showed me : catalog/category/view/id/418
i.e. Catalog : Module, Category : Controller and ViewAction method. This is ok, i can find this.
But i come across this url http://example.net/index.php/products/cat/483.html And i can't find this searching on url rewrite management. (i searched for products/cat/,products/cat/483.html) and i don't see any thing related to this.
So where can i look for this? How is this being routed ? And this url http://example.net/index.php/products/cat/483.html is populating list of products under that category id 483.
Check .htaccess for redirects to this url. But in the end it is still probably processed by catalog/category/view method.

Magento - passing params in URL to template file

I have a template file at ../page/video.phtml and it's served at http://mysite/video.
I want to add params in the url to play different videos on that page. I can add it as a query string param, http://mysite/video?select=filename but I would prefer to use http://mysite/video/filename.
However, when I try this I get a 404. What would I have to do to achieve this?
I'm using Magento 1.7
You must explicitly include all the action parts (route, controller and action) in the URL before adding parameters this way, because when you use http://mysite/video/filename, Magento looks for the index action of the filename controller for the module having a front route named video (which does not exist, hence the 404 error).
From the URL you gave, a working URL would rather look like this : http://mysite/video/index/index/select/filename

changing url displayed to user in codeigniter

I don't know if this is strange request or not, but I have a page with users profiles displaying. Each user has unique username of course and those are included in links to associated with their names. when clicked it goes to their profile:
profile/profile_guest/username
When the user clicks on one of the profiles, it goes to user's profile and url in the address bar is:
http://domain.com/profile/profile_guest/ahlam
What I want to achieve is to configure routes.php to handle this. so once clicked, it goes to profile page but what shows in URL address bar is :
domain.com/ahlam
To do that, I tried :
$route['someTest'] = "profile/profile_guest/$1";
Fair to say that it didn't work and still the whole URL displayed. What can I do to fix this?
Thanks all
You should use something like
$route['sometest/(:any)'] = "your/link/$1";
The '$1' is like a parameter you gonna receive from the '(:any)' part.
//site.com/john = "profile/profile_gest/john"
$route['([a-z0-9\-_]+)'] = "profile/profile_gest/$1";
//where $1 = "john", so "john" respects the pattern set below
But CI Routing will understand any URI match this pattern like "index", "post", ... is a routing for the profile controller.
TO prevent that you can add a specification to the url, for examples:
//site.com/john.html
$route['([a-z0-9\-_]+)\.html'] = "profile/profile_gest/$1";
//site.com/user-john
$route['user\-([a-z0-9\-_]+)'] = "profile/profile_gest/$1";
Or
if you are sure that any usernames will not contest with an another pages
always put this rules at the bottom, in order to that CI will check all other routing rules before this one.
Note: Before that your htaccess have to be set to remove index.php from your urls.
CI URI Routing
Regular expression

Resources