View Single Post
  #1  
Old 03-22-2019, 06:09 AM
 
welly welly is offline
 

eXpert
  
Join Date: Mar 2011
Location: UK
Posts: 209
 

Default Problem with custom module

Hi there

I am using the Loyalty Program module, and I am using a static page to describe how it works rather than the standard blurb.

The static page has it's own page heading, but if I use the '?target=loyalty_program_details' method reference the loyalty program, the page heading is hardcoded as 'Loyalty Program Details'. My page heading is ignored.

I thought the page heading might be a label, but it isn't. It seems to be defined in the file classes/XLite/Module/QSL/LoyaltyProgram/Controller/Customer/LoyaltyProgramDetails.php in the getTitle() function.

I can edit this file and change the heading, and I will do if I have to, but I think the correct method would be to create a custom module, and replace this function with my own version. Unfortunately, even though I am fairly sure I have done this correctly (I have created other simple modules which seem to work fine), I just can't get this one to do what I want.

So, I created my customer module with a copy of the LoyaltyProgramDetails.php file, which now contains the following:

-----------------------------
<?php

namespace XLite\Module\<mydevdir>\LoyaltyProgram\Module\QSL\ LoyaltyProgram\Controller\Customer;

/**
* Controller for the "Loyalty Program Details" page.
*/
abstract class LoyaltyProgramDetails extends \XLite\Controller\Customer\ACustomer implements \XLite\Base\IDecorator
{
/**
* Return the current page title (for the content area).
*
* @return string
*/
public function getTitle()
{
return 'Earn as you shop with our Loyalty Programme';
}
}
-----------------------------

The module is visible/available on the admin side and is switched on, and the differences between my version and the original are the namespace declaration, the class declaration (was 'class LoyaltyProgramDetails extends \XLite\Controller\Customer\ACustomer'), and the function's return line (was 'return 'Loyalty Program Details';'). I also removed the only other function, getLocation(), but not surprisingly it makes no difference whether it is in my php file or not.

My understanding is that the class declaration with 'implements \XLite\Base\IDecorator' means that I am replacing something in the class and not extending it, but for whatever reason, my changes aren't having any effect.

Is there anything I'm missing? Am I making a simple schoolboy error that I just can't see for looking?

I'm not sure how to go about diagnosing it or where to look to see what is going on, and although it isn't a major problem and I can edit the original file to achieve what I want, I feel that this is the right way to do it and that I must surely be close to getting it right!

I'm hoping it will be easy to put track down.

Many thanks

Welly
__________________
X-Cart Business 5.3.6
Various add-ons

www.traininglines.co.uk
Reply With Quote