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

Can't get a custom page to load

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 05-03-2016, 01:10 AM
 
Stormer Stormer is offline
 

Member
  
Join Date: May 2016
Posts: 15
 

Default Can't get a custom page to load

Help!

I need to create a page that I can put some HTML in, but I can't seem to get the page to load. It just redirects back to the homepage. Here's what I'm trying:

1) I run the following macro from the SDK: php.exe ../next-sdk/devkit/macros/create-module.php --module=MyDevID\TestMod --version=5.2

2) Then I run: php.exe ../next-sdk/devkit/macros/create-page.php --module=MyDevID\TestMod --target=testmod --interface=Customer --version=5.2

3) Next I edit <xcart_dir>/skins/default/en/modules/MyDevID/TestMod/page/testmod/body.tpl and add <p>Hello World</p>

4) I redeploy the site and then enable the "TestMod" module

5) Finally I go to http://<mycarturl>/cart.php?target=testmod and it just redirects me to the store's homepage.

Am I skipping a step on setting this up or is there something wrong with the cart installation?

Thank you!
__________________
X-Cart 5.3
Reply With Quote
  #2  
Old 05-03-2016, 09:25 AM
 
Stormer Stormer is offline
 

Member
  
Join Date: May 2016
Posts: 15
 

Default Re: Can't get a custom page to load

Turns out it's the Clean URL feature causing the problem. If I turn it off, it directs me to my module. How can I create a clean url for my module so it works?
__________________
X-Cart 5.3
Reply With Quote
  #3  
Old 05-03-2016, 12:17 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Can't get a custom page to load

It's not that. One of the functions returning redirect url for Clean URL changed with recent versions. The SDK is old, it hasn't been updated for like 2 years. You can use it as starter but do not rely on it. It looks like QT abandoned it.

I believe the one changed was \XLite:getTargetByCleanURL() or similar
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
Stormer (05-03-2016)
  #4  
Old 05-03-2016, 12:37 PM
 
Stormer Stormer is offline
 

Member
  
Join Date: May 2016
Posts: 15
 

Default Re: Can't get a custom page to load

It look the solution was more straight forward, I just changed the URL from the URL suggested in the documentation (which was http://<mycarturl>/cart.php?target=testmod) to http://<mycarturl>/?target=testmod.

Ugh, what a waste of precious development time. But thanks for replying Steve!! Without the handful of dev guys on this forum, XC5 would be dead in the water!
__________________
X-Cart 5.3
Reply With Quote
  #5  
Old 05-03-2016, 01:00 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Can't get a custom page to load

Thse 2 urls are essentially the same so this is not really a solution. The problem with this is it will add the parameter to the clean url so in general will look like

www.domain.com/this-is-test-pahe.html?target=testmod

Not pretty or easy to remember and it sort of defeats the purpose of having clean urls.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
Stormer (05-03-2016)
  #6  
Old 05-03-2016, 02:13 PM
 
Stormer Stormer is offline
 

Member
  
Join Date: May 2016
Posts: 15
 

Default Re: Can't get a custom page to load

Bizarre! But thanks, it works!
__________________
X-Cart 5.3
Reply With Quote
  #7  
Old 05-03-2016, 10:23 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Can't get a custom page to load

Hello!

I've just tested it on my local X-Cart 5 installation and both the links (http://<mycarturl>/cart.php?target=testmod and http://<mycarturl>/?target=testmod) display the test page when Clean URLs are enabled.

Did you enter the links in your browser's address bar? Or did you use some kind of a menu link to that page?
__________________
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
  #8  
Old 05-04-2016, 01:10 AM
 
Stormer Stormer is offline
 

Member
  
Join Date: May 2016
Posts: 15
 

Default Re: Can't get a custom page to load

I tried both typing in the URL and creating a menu link.

It was working, but now it has mysteriously stopped working regardless if the Clean URL's are enabled or not.

Any suggestions on how I can debug this? How can I confirm that the target loading my module?
__________________
X-Cart 5.3
Reply With Quote
  #9  
Old 05-04-2016, 10:35 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Can't get a custom page to load

Can you send me your module? You can use this method to pack it into a single archive file.

As for debugging - you can use this code to log data to a custom log file:
Code:
\XLite\Logger::logCustom('your-log-name', var_export(array('param1'=>$param1, 'param2'=>$param2, ...), true));

Log the result of the getTarget() method in the first line of the handleRequest() method in the var/run/classes/XLite/Controller/AControllerAbstract.php file - this should give you the idea what "targets" are being triggered.

Also, you can add "protected function doNoAction()" method in your controller class (classes/XLite/Module/MyDevID/TestMod/Controller/TestModController.php) and add logging there.

Just remember that "var/run/classes/" contains the actual PHP files that are run when you browse the site, and "classes/" is the directory that stores "original" versions of these files (every time you redeploy the store X-Cart 5 takes these files, "compiles" them and put inside the var/run/classes/ directory).
__________________
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

Last edited by qualiteam : 05-04-2016 at 10:37 PM.
Reply With Quote

The following user thanks qualiteam for this useful post:
Stormer (05-05-2016)
  #10  
Old 05-05-2016, 08:47 AM
 
Stormer Stormer is offline
 

Member
  
Join Date: May 2016
Posts: 15
 

Default Re: Can't get a custom page to load

Thank you for the logging code, I will try it out.

I was able to fix my issue by changing the target tag in the code from testmod to test_mod. I am not sure why I had to change it, I'm guessing it's a bug in the deployment process, but it did allow the module to load when I request it with http://<mycarturl>/placeholder.html?target=test_mod
__________________
X-Cart 5.3
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



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 11:54 AM.

   

 
X-Cart forums © 2001-2020