In opencart, how to get the url of the side store - opencart

I created another store in opencart, how can I get the url of the other store in controller?
Thanks,Ron

The url will be which you put at the creation of the store in Store Url Field
checkout this tutorial.
http://code.tutsplus.com/tutorials/create-a-multi-store-setup-using-opencart--cms-22261
To get all store list at controller
$this->load->model('setting/store');
$results = $this->model_setting_store->getStores();
the results will contain the stores information with id, name, url

Related

Appending DB object string to dynamic urls in Django

I need to append a string stored in DB. e.g ?linkappend which is stored as a DB object link_append to all ebay links that will be displayed in a page. I think I should use template tags but not sure how to go about it.
You say that link_append is an object in the database? How is it stored? How does your view look like?
Because, if link_append is just represented by a ModelField, then it should be fairly easy to append it to the links by adding it as a template-variable like so:
The part after "?" {{ obj.link_append }} does place the content of that ModelField in the GET-part of the link.

Django redirect to form page and submit the form?

Right now. I have a search function in my page to search for item id. When I click search, I will render the same page with the result items and show item. And in other pages where I also display the item id, I want to add a link to the id to go to the same page where I search for that id.
Example: id: 123, I want the same page when:
1. search '123' in my search page(my search only accept exact match)
2. In other pages, click '123', go to the search page with results
How should I achieve this, I have tried many ways which don't wok.
You need to make use of the GET method that HTML forms provide. When you perform a search from the first page, you must make sure that you are doing so using the GET method in the form. This will append the form data into the URL.
E.g. If you have a 'name' field in your form which has 'John' inputted. The submission of this form will compose a URL like so:
http://someurl.com/?name=John
This can then be accessed using the Django request object:
name = request.GET['name']
You've probably done something similar already for displaying your search results. So, all you need to do is create a link in your second page that redirects to the search page with GET request variables appended.
E.g.
<a href="{% url 'search_page' %}?searchterm=232> Item 232 </a>

Sitecore: How to get a Hyperlink Manager Url from a General Link Field

In the sitecore Rich Text Editor, user can highlight some words and insert a hyperlink. User can select a media item and it will generate a url like ~/media/9A3E8962D4364D0A9F98178A9572CC08.ashx
I have a general link field, what code should I write to generate the above Url? I have tried GetMediaUrl and GetItemUrl method, but they both return the file location.
My goal is that I need to get a url from a field which look like ~/media/9A3E8962D4364D0A9F98178A9572CC08.ashx. Should I use a different type of field? The file which the link is pointing to is a pdf.
You should pass custom MediaUrlOptions to get desired URL format:
var mo = new MediaUrlOptions();
mo.UseItemPath = false;
var url = Sitecore.Resources.Media.MediaManager.GetMediaUrl(imageField.MediaItem, mo);
UseItemPath indicates whether item path or item id should be used for URL.

How to hide a View parameter from the URL in Django?

I have a view which displays the objects of a model. The objects are sorted using a key which I want to have as a view parameter so that I can create a system where the user gets to pick on how to sort the query sets.
I currently have it set up as follows:
def comics(request, sorting_key):
comics = Comic.objects.all().order_by(sorting_key)
...
However, the problem is that I need to include the sorting key somewhere in the url as well, and I don't want that. Is there any way to get around this problem? Or am I stuck with an URL that explicitly shows the sorting key?
You can make use of cookies, you can set cookie on client browser when user changes the parameter of sorting and reload the page to sort the data, which will call the same view again, read the cookie from request in your view and sort on that parameter.
Do take care of default parameter when cookie is not set or sorting on that key is not available, because user can change or delete the cookie.
You can replace the <a> tags in the menu links with <form> tags with the same URL, and send the sorting key using post, and read it from request.POST in the view.

How to organize URLs in django for views handling GET data and parsing URL?

I have a view that displays some movie data. I thought that it might be a good idea to have a view handle a an URL like movie-id/1234 to search for movie id 1234. Furthermore I would like to be able to enter the ID into a form and send that to a server and search for it. To do that I created a second entry in the urls.py file shown below.
urlpatterns = patterns('',
url(r'movie-id/(?P<movie_id>.+?)/$', 'movieMan.views.detailMovie'),
url(r'movie-id/$', 'movieMan.views.detailMovie', name='movieMan.detailMovie.post'),
)
So if I want to pass data to my view either via a URL or a GET or POST request I have to enter two urls or is there a more elegant way? In the view's code I am then checking if there is any GET data in the incoming request.
To make the second url usable with the template engine, where I wanted to specify the view's url using the {% url movieMan.detailMovie.post %} syntax I had to introduce a name attribute on this url to distinguish between these two.
I am not sure if I am thinking too complicated here. I am now asking myself what is the first url entry good for? Is there a way to get the URL of a movie directly? When do these kinds of URLs come into play and how would they be generated in the template ?
Furthermore I would like to be able to enter the ID into a form and
send that to a server and search for it.
Is this actually a search? Because if you know the ID, and the ID is a part of the URL, you could just have a textbox where the user can write in the ID, and you do a redirect with javascript to the 'correct' URL. If the ID doesn't exist, the view should return a Http404.
If you mean an actual search, i.e. the user submitting a query string, you'll need some kind of list/result view, in which case you'll be generating all the links to the specific results, which you will be sure are correct.
I don't think there is a more elegant way.
I did almost the same thing:
url( r'^movies/search/((?P<query_string>[^/]+)/)?$', 'mediadb.views.search_movies' ),
The url pattern matches urls with or without a search parameter.
In the view-function, you will have to check whether the parameter was defined in the url or in the query string.