Code Guide 2018/10/16
Controllers
Controllers contain the methods that give an answer to the routes defined in the application.
PageController
index() method where the main logic of the application is located. Almost all
routes go to this controller, which finds the corresponding page to show, loads its related
data and shows it.
The most important methods are:
- frontendRestriction() – used to restrict a page to only logged in front-end users. If the user is not logged in they will be redirected to the login page.
- guestRestriction() – used to restrict a page only to not logged in front-end users. If the user is logged in they will be redirected to the page that they were was trying to see before logging in.
- showOneMapRestriction() – used to show a page only if the setting show_one_map is true. If it’s not true it will redirect to the map selection page.
- showTwoMapsRestriction() – used to show a page only if the setting show_one_map is false. If it’s true it will redirect to the single map page.
- getPageFromExactUrl() – find if a page exists with the exact url.
- getPageFromUrl() – find a page in the “tree” of url slugs. For example,
with /equipment/heating/yutaki the method will follow these steps to show the product
page:
- equipment = first level page, which has in its config that its children are of type range.
- heating = ‘range’ page which has in its config that its children are of type product.
- yutaki = ‘product’ page.
- loadPageData () - loads the data to show on the page using the page config information.
- getSearchData() - on search page, load search results using the passed filters.
- getResourceData() - on resources page, load search results using the passed filters.
- getPageElementsDataFromDB() - load other page elements as defined in page config.
- getPageTranslatedData() - load page translations.
- getSeoData() - load the SEO related data.
ContactController
- send() method – receives contact forms and sends them to the e-mail configured in settings -> contact_form_mailto, and saves them in the database.
DistributorController
- index() method – returns a json list of the distributors of a type if specified in the request, or of both types distributor and installer if not specified
DownloadController
- download() method – returns a download file related to the specified resource if the user is logged in.
- download_datatable() method – returns a download file related to a product technical data (datatable).
NewsController
- paginate() method – loads 4 more news items.
ProjectController
- paginate() method – loads 4 more projects (of a category if specified in the request).
SearchController
- nSearch() method – shows a list of results for quick searches in the search bar.