View Single Post
  #6  
Old 04-25-2016, 08:56 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Front page conditional for X-Cart 5 Flexy templates?

Quote:
Originally Posted by paulmighty
Do you have any suggestions on how to learn what functions are available for X-Cart 5?

Every page has a controller class that handles its logic. You can find these classes in the \XLite\Controller\Customer namespace.

The name of the controller class is determined from the "target" parameter. The default "target" is "main", that links to the \XLite\Controller\Customer\Main controller class. It is the home page.

When you submit some data and want the controller to perform some action, you also submit the "action" parameter. X-Cart 5 checks the controller class, finds a matching "doAction{your_action}()" method and executes it.

If there is no "action" parameter, X-Cart 5 executes the "doNoAction()" method. There is another method that is executed every page load: "handleRequest()".

When the controller class has completed its work, X-Cart 5 starts rendering the page. The logic is as follows:
- it renders the base template that adds multiple "view lists"
- it looks for templates and widget classes having "@ListChild" directive and renders these into the "view lists" that are specified in the directive
- these templates may add their own "view lists", so this is some kind of a loop
- if a widget class wants to limit the "targets" where it should be rendered, it can use the static "\XLite\View\AView::getAllowedTargets()" method

Inside template files you can access methods provided by the associated widget class and the controller class for the current "target". When you run something like "getTarget()" inside your template, X-Cart 5 looks for that method in the current widget class, and, if it is not there, it looks for the method in the controller class. "getTarget()" method is the controller's method that comes from the "\XLite\Controller\AController" class.

When you render a base template, the associated widget class is \XLite\View\Controller. But as soon as you start rendering a widget, that widget's class becomes the "current" widget for all templates it renders (unless some other nested template renders another widget).

I hope this clears the logic a bit.

You may also check the existing source code and our knowledge base for examples - this may really help.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote