0

Im developing an X-Cart 5 site and need to add custom html on the homepage (a.k.a. storefront).

Using the X-Cart development documentation, I created a custom module and added the modifications to the Crisp White template using the @ListChild directive.

But, since I used the ListChild with list=center.bottom , my custom module shows on every page. We only want the code to appear only on the home page.

I have several questions:

  1. Which @ListChild values can I use to display the module only on homepage?

  2. Is there a website where I can see a list of all the available @ListChild values? I searched in X-Cart documentation and can't find a list of available ListChild positions.

  3. If it's not possible using ListChild, I know we can query the current page inside the template. How to test if the current page is the homepage?

Thanks again for all the help.

DarkBee
  • 16,592
  • 6
  • 46
  • 58
F Torres
  • 1
  • 1

1 Answers1

1

1) You are using too generic view list to insert your template. list=center.bottom is indeed a part of each page. You may want to check a page structure of a page via Webmaster mode and find more specific view list.

Alternatively you can create a viewer class that will display your template: https://devs.x-cart.com/design_changes/ways-to-apply-design-changes.html#registering-viewer-class-in-view-list

and specify what pages to display this class on. For that you need to create following method inside your viewer class:

public static function getAllowedTargets()
{
    return array_merge(parent::getAllowedTargets(), array('main'));
}

// main is a target of the home page

  1. There is no web-site for seeing all available view lists, but you can either look them up for a specific page via Webmaster mode https://devs.x-cart.com/design_changes/ways-to-apply-design-changes.html#seeing-structure-of-specific-page or you can see all view lists and templates assigned to them in the xc_view_lists MySQL table.

  2. You cannot check that inside a template, but you can get its value in a class like this:

    \XLite\Core\Request::getInstance()->target;
    
Tony
  • 149
  • 5