Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Problem with custom module

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #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
  #2  
Old 03-22-2019, 12:45 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Problem with custom module

I think you should extend XLite\Module\QSL\LoyaltyProgram\Controller\Custome r\LoyaltyProgramDetails class instead of XLite\Controller\Customer\ACustomer in your module.
I would try that out first.
__________________
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
  #3  
Old 03-22-2019, 02:33 PM
 
welly welly is offline
 

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

Default Re: Problem with custom module

Hi Alex

I think you are right, but I have changed my class line as follows, and it still doesn't work:

abstract class LoyaltyProgramDetails extends \XLite\Module\QSL\LoyaltyProgram\Controller\Custom er\LoyaltyProgramDetails implements \XLite\Base\IDecorator

Is that what you had in mind?

Many thanks for the suggestion.

Welly
__________________
X-Cart Business 5.3.6
Various add-ons

www.traininglines.co.uk
Reply With Quote
  #4  
Old 03-25-2019, 03:08 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,431
 

Default Re: Problem with custom module

Hi @welly,

The problem is likely to be caused by wrong namespace.
Could you please let me know what namespace of your custom class?
And what path it is at?

Thanks.

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
  #5  
Old 03-25-2019, 05:47 AM
 
welly welly is offline
 

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

Default Re: Problem with custom module

Hi Tony

It seems that the problem was more simple than that.

As I was copying and pasting the relevant lines from the original and my version of the php file into this reply, I noticed that I had added a comment with the previous version of the class declaration in it. I assume I had not formatted it correctly because now I have removed it, the module works as intended.

Many thanks for your help.

Welly
__________________
X-Cart Business 5.3.6
Various add-ons

www.traininglines.co.uk
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 03:22 PM.

   

 
X-Cart forums © 2001-2020