| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Simple CMS module and custom page code | ||||
|
|
Thread Tools | Search this Thread |
#11
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
after knocking my head on this for nearly a week, I cannot for the life of me figure out what I'm doing wrong, which class I need to extend (and/or decorate), whether I am to use view, model, or controller .. there doesn't seem to be any detailed information anywhere of anyone else trying this for me to build my ideas on, and I don't yet have enough basic knowledge of x-cart 5's functionality despite all the tutorials due to their un-fleshed-out nature.
I created classes/XLite/Module/MY-ID/MY-MODULE/View/Page.php and added the following Code:
even if $cnd is wrong, AND there is no search functionality in this for the Repo, I should STILL get a log of the current page ID and don't get that either. where am I going so totally wrong?
__________________
-- Scott Godin |
|||||||||
#12
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
You have to extend the Page class from the CMS module not the AView class
__________________
Steve Stoyanov CFLSystems.com Web Development |
|||||||||
#13
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
Quote:
ahhhhhhhhhhhh. I was coming to suspect that, but after so much flailing, rather than yet another TIAS, I figured it was smarter to just ask. Thanks, now let's see what's what.
__________________
-- Scott Godin |
|||||||||
#14
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
there was also a typo in my earlier code:
Code:
see it? strangely, that generated no error. and after fixing Xlite to XLite, NOW I get the error about the extra parenthesis on line 45. not before.
__________________
-- Scott Godin |
|||||||||
#15
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
still nothing.
Code:
even tried renaming the file from Page.php to PGPage.php and adjusting the class accordingly. I still get nothing from the Logger, which means that code isn't running when the Simple CMS Page is running.
__________________
-- Scott Godin |
|||||||||
#16
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
okay it's not \XLite\Module\CDev\SimpleCMS\View\Page I need to extend, but \XLite\Module\CDev\SimpleCMS\View\CustomerPage
now I have to figure out the right way to make the search work
__________________
-- Scott Godin |
|||||||||
#17
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
I've managed to 'fake' my way through the search bit by doing the following, and so long as I have css and js aggregation turned off, this works, but I'm curious why when css+js aggregation is ON, it doesn't pull in the external resources from the CDN this way ... as I AM adding them with url and not file parameter.
I still have to learn how to do the getRepo(...)->search() bit correctly, but I'm far closer than I was. any pointers would be appreciated Code:
__________________
-- Scott Godin |
|||||||||
#18
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
neither http://kb.x-cart.com/display/XDD/Speeding+up+your+store#Speedingupyourstore-Step1.EnableCSS,JSaggregationandwidgetcaching nor http://kb.x-cart.com/display/XDD/Adding+CSS+and+JS+files have any information on why css/js aggregation under Look and Feel > Performance, when enabled, fail to load resources added via URL rather than FILE, from within a Module so I can leverage the awesome https://cdnjs.com/
I tried to do everything I could to find out the right way to include the links short of saving and serving them locally, and when css/js aggregation is OFF, everything works fine. I would *expect* it would add the external resources as separate LINK and SCRIPT tags when aggregation is on, but that does not appear to be happening. bug? or did I miss something
__________________
-- Scott Godin |
|||||||||
#19
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
A few notes on your code:
1. You don't need getAllowedTargets() and getDefaultTemplate() methods in your class as they exist in the original widget class. 2. For easier tracking which classes extend what other classes it makes sense to rename your class from PGPage to CustomerPage (as the original class that you modify from your module). 3. Instead of searching a page with the given name, it will be easier to get the current page and check its name. 4. View classes can use public methods declared in the controller used for the current page. In case of SimpleCMS pages the controller class is \XLite\Module\CDev\SimpleCMS\Controller\Customer\P age that already has getPage() public method. It makes sense to use these methods instead of trying to retrieve the current page by using the Repo class. 5. It makes sense to put the code that checks if it is the gallery page into a separate method. 6. Having one return operator per method is a good practice. You should avoid multiple returns per method when possible. So, I would change your code as follows: PHP Code:
Quote:
If you add a resource with the "url" key, not "file", X-Cart 5 won't aggregate the file. So, this should work as you expect.
__________________
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 : 01-25-2016 at 04:45 AM. |
|||||||||
#20
|
|||||||||
|
|||||||||
Re: Simple CMS module and custom page code
Quote:
no I wasn't expecting it to aggregate the file.. what I WAS expecting, however is that it would append separate link/script tags AFTER the aggregation's css/js link. Because right now if I enable aggregation, the external urls are NOT added to the html AS external urls. What I expected: HTML Code:
What I got: HTML Code:
your aggregation codebase currently fails to append the external urls, and does not report the issue in logging.
__________________
-- Scott Godin |
|||||||||
|
|||
X-Cart forums © 2001-2020
|