X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Simple CMS module and custom page code (https://forum.x-cart.com/showthread.php?t=73346)

Scott Godin 01-28-2016 07:29 AM

Re: Simple CMS module and custom page code
 
anything ?

(I find I am also particularly distressed by the fact this board practices revisionist history and has deleted the numerous posts by me on a daily basis while looking for responses from the community, in order to keep my post from falling into obscurity)

I find that I much prefer the news:// format, as is continuing to be used by gmane.org, which provides a bidirectional gateway to various mailing lists, using a newsreader format. lists are much easier to follow, fewer posts get lost in obscurity on 'page 2+', it's more compact to review post titles with, etc. The majority of Web Forum formats are, by their very nature, far less efficient

cflsystems 02-03-2016 07:15 AM

Re: Simple CMS module and custom page code
 
If you want a definite answer you should do this under your QT Helpdesk account.
The forum is free resource where ppl like me contribute their own time to post/answer. But nothing in here is guaranteed for quality, time, etc.

In many cases for many tasks you can hire a professional outside QT but in this case for the question on how XC5 works with js/css aggregation you should ask QT - they are the developer of XC5 and they should know the answer. This is way too much in the core of the system for anyone else to have indefinite answer.

And it is possible that XC5 just works in this way or this is a bug or not coded or....

Scott Godin 02-04-2016 07:20 AM

Re: Simple CMS module and custom page code
 
I was sort of thinking to not jump the gun here, but instead look for correspondence with qualiteam on this who can

A> confirm it is a bug and that i should report it,
B> Confirm it is a bug that has already been reported (with link to bug),
C> confirm a fix is already in the works for known bug and it should be out in the next release, or
D> I'm doing it wrong, it doesn't work that way, we aren't going to fix this, deal with it, etc

I had previously been doing ALL my correspondence with tech support directly, and switched to the forums for certain things, after discussion with the team, to help spread the load around a little better.

qualiteam 02-09-2016 09:17 PM

Re: Simple CMS module and custom page 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.

I've just tried this on my local X-Cart 5 installation and it works there exactly as I said in my previous post - it does not aggregate external scripts.
Here is what I see in the page source code:
Code:

...
<script  type="text/javascript" src="http://xcart/xc5/src/var/resources/js/343a30b273e2ec6c0a3f7e93f23c86c58e081f64b4faa9d3b88d21de2580196f.js?1455030625"></script>
<script  type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/nanogallery/5.9.1/jquery.nanogallery.min.js?1455030625"></script>
<script  type="text/javascript" src="http://xcart/xc5/src/var/resources/js/89ebbd66d82942e4e11f9f6c8f10f3caa73809350359d5d0210ff70502716007.js?1455030625"></script>
...


The code was:
PHP Code:

public function getJSFiles()
    {
        
$files parent::getJSFiles();

            
$files array_merge(
                
$files,
                array(
                    array(
                        
'url' => "//cdnjs.cloudflare.com/ajax/libs/nanogallery/5.9.1/jquery.nanogallery.min.js",
                        
'no_minify' => true
                    
),
                )
            );
 
        return 
$files;
    } 


Scott Godin 02-10-2016 03:19 AM

Re: Simple CMS module and custom page code
 
What version of x-cart are you running? We are on 5.2.10 currently because I'm still awaiting correspondence about an import/export bug in our current install that is holding up our desire to upgrade the devel server.

The code I have reads as follows, and is stored at classes/XLite/Module/MHG/TemplateMods/View/CustomerPage.php:

Code:

<?php
// vim: set ts=4 sw=4 sts=4 et ft=php.html:


namespace XLite\Module\MHG\TemplateMods\View;

class CustomerPage extends \XLite\Module\CDev\SimpleCMS\View\CustomerPage implements \XLite\Base\IDecorator
{

        public function getCSSFiles()
        {
                $files = parent::getCSSFiles();

                if ( $this->isGalleryPage() )
                {
                        $files = array_merge(
                                parent::getCSSFiles(),
                                array(
                                        array(
                                                'url' => "//cdnjs.cloudflare.com/ajax/libs/nanogallery/5.9.1/css/nanogallery.min.css",
                                                'media' => 'screen',
                                                'no_minify' => true,
                                        ),
                                        array(
                                                'url' => "//cdnjs.cloudflare.com/ajax/libs/nanogallery/5.9.1/css/themes/light/nanogallery_light.min.css",
                                                'media' => 'screen',
                                                'no_minify' => true,
                                        )
                                )
                        );
                }
                return $files;
        }

        public function getJSFiles()
        {
                $files = parent::getJSFiles();

                if ( $this->isGalleryPage() )
                {
                        $files = array_merge(
                                parent::getJSFiles(),
                                array(
                                        array(
                                                'url' => "//cdnjs.cloudflare.com/ajax/libs/nanogallery/5.9.1/jquery.nanogallery.min.js",
                                                'no_minify' => true
                                        ),
                                        array(
                                                'file' => 'modules/MHG/TemplateMods/nanogallery_local.js'
                                        )
                                )
                        );
                }
                return $files;
        }
        protected function isGalleryPage()
        {
                // Use the getPage() method of the controller class to get the current page object
                $currentName = $this->getPage()->getName();

                return "Photo Gallery" === $currentName;
        }
}


If I disable aggregation, the external files load along with the rest and the gallery works.
If I enable aggregation, the external files get dropped on the floor, never get loaded in the page content as external separate urls from the aggregated css and js files and the gallery stops working.

qualiteam 02-10-2016 08:32 PM

Re: Simple CMS module and custom page code
 
Hello Scott,

I'm using the most recent 5.2.12 version. Try to install a fresh X-Cart 5.2.12 and test your custom module there.

Also, try to remove the isGalleryPage() check from getJSFiles() and make the external script loaded on every page. If this helps, the cause may be some kind of a page cache.

Scott Godin 02-11-2016 07:55 AM

Re: Simple CMS module and custom page code
 
Quote:

Originally Posted by qualiteam
Hello Scott,

I'm using the most recent 5.2.12 version. Try to install a fresh X-Cart 5.2.12 and test your custom module there.


am awaiting word on another bug report to tech support before I make the update

Quote:

Also, try to remove the isGalleryPage() check from getJSFiles() and make the external script loaded on every page. If this helps, the cause may be some kind of a page cache.

Nope, that didn't work either. Hopefully the 5.2.12 update will help.

Scott Godin 02-11-2016 08:51 AM

Re: Simple CMS module and custom page code
 
It looks like the 5.2.12 update was the fix for this.. I don't know why it took so long to find this information out -- wouldn't it have been simpler to just say "oh, this was fixed in 5.2.12, just update when it is released" weeks ago?

argh. Such knowledge would have saved us a lot of frustration on this end, I can assure you.

qualiteam 02-16-2016 08:23 AM

Re: Simple CMS module and custom page code
 
I would definitely told you that if I had known it.
But I thought it may be the cause. That's why I advised you to test your code on a "fresh" installation of 5.2.12 (not upgrade your existing site!).

sales@webosusa.com 05-08-2019 04:58 AM

Re: Simple CMS module and custom page code
 
This will sove your issue...
https://market.x-cart.com/addons/custom-header-assets.html


All times are GMT -8. The time now is 06:10 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.