X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   News and Announcements (https://forum.x-cart.com/forumdisplay.php?f=28)
-   -   Webinar for X-Cart 5 developers on March,18th. (https://forum.x-cart.com/showthread.php?t=68723)

cflsystems 04-01-2014 11:51 AM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Yes it runs only from the command line. Yes I can use it. And while on Win system most of the time I have an old computer on my internal network running Linux server so I can run proper hosting, not Win, not something simulated.
Get your old x86 laptop and just install Ubuntu Server on it - it will run even on 256MB RAM :) not like Win which will require GBs of RAM just so you can load the system....

tony_sologubov 04-02-2014 03:28 AM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Hi Mike!

I don't have Win machine to test it out, but I believe you can call next-sdk like this on Win:
Code:

C:\path\to\php\bin ../../next-sdk/devkit/macros/create-module.php --module=Tony\\News --version=5.0

These resources can be helpful as well:
http://stackoverflow.com/questions/15597067/how-to-run-php-from-windows-command-line (explains how you can call it like > php ../../next-sdk/devkit/...)
http://www.php.net/manual/en/install.windows.commandline.php

totaltec 04-02-2014 07:27 AM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Steve, yes I think I need to bite the bullet and start running Linux again on an old system. Thanks for the advice.

Tony,
I am going to test it out, really appreciate you taking the time to find those resources for me!

Thanks,
-Mike

totaltec 04-02-2014 09:35 AM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Yay, thanks guys, I got it to work on Windows.

One thing that may be obvious to others that wasn't to me, you need to run the script from within the XC5 installation directory. At first I was wondering, how does the macro know where XC5 is installed? :-)

So for me, my path to php is C:\\xampp\php\php.exe
Path to next-sdk is C:\\xampp\htdocs\next-sdk\
Path to XC5 C:\\xampp\htdocs\xcart\

Running the script within the xcart directory the correct usage was:
..\..\php\php.exe ../next-sdk/devkit/macros/create-module.php --module=Tony\News --version=5.0

Note that using --module=Tony\\News caused an error. May be a quirk related to Windows only, I see that Tony was able to use the double slashes like --module=Tony\\News in his tutorial video.

Anyway, it works, and I learned something new, which is always great. Thanks again.

totaltec 04-03-2014 12:19 PM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Found time to finish working through the tutorial. There is a typo in this section:
"Update controller
Edit the classes/XLite/Module/Tony/News/View/Model/NewsEdit.php file and add the following code there:"

The file path is wrong, it should be:
"classes/XLite/Module/Tony/News/Controller/Admin/NewsEdit.php"

Also, I added this code to the News controller in classes/XLite/Module/Tony/News/Controller/Customer/NewsEdit.php:
Code:

        public function getNewsTitle()
        {
            $id = intval(\XLite\Core\Request::getInstance()->news_id);
 
 
            $return = '';
 
 
            if ($id != 0)
            {
                $news = \XLite\Core\Database::getRepo('XLite\Module\Tony\News\Model\News')->find($id);
 
                if ($news) {
                    $return = $news->getTitle();
                }
            }
 
 
            return $return;
        }

    /**
    * Return the current page title (for the content area)
    *
    * @return string
    */
    public function getTitle()
    {
        return 'News';
    }

    /**
    * Common method to determine current location
    *
    * @return string
    */
    protected function getLocation()
    {
        return $this->getTitle();
    }

This allowed the section name "News" to be displayed in the bread crumb area and the page title. It also allowed me to use the function getNewsTitle() to display the title on the news page in the customer area after adding the following code to skins/default/en/modules/Tony/News/page/news/body.tpl
Code:

<h2>{getNewsTitle():h}</h2>

Thanks again for this learning experience, I feel much better about XC5 and my own ability to work with it.

totaltec 04-06-2014 09:31 AM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Tony,
I hope you are still watching this thread, and I hope this is a good place to continue asking questions related to the webinar. I have attempted to take your News module a bit further, and currently I am stuck on creating the ability for translations.

I added a class in XLite\Module\Tony\News\Model\NewsTranslation.php
with the following code:
Code:

<?php

namespace XLite\Module\Tony\News\Model;

/**
 * News
 *
 * @Entity
 * @Table (name="news_translations",
 *      indexes={
 *          @Index (name="ci", columns={"code","id"}),
 *          @Index (name="id", columns={"id"})
 *      }
 * )
 */
class NewsTranslation extends \XLite\Model\Base\Translation
{
  /**
    * @Column (type="string", length=255)
    */
  protected $title = '';
 
 
  /**
    * @Column (type="text")
    */
  protected $body = '';
}


I imitated the SimpleCMS module code. I see that there are many instances where the translation ability has been added in this way. But when rebuilding I get this error:
ERROR: "30" (code N/A)

There is no column with name 'id' on table 'xc_news_translations'.

Now, I understand that this means we are missing this column, and that it is referenced in the PHPDoc comment so it must exist. But the other modules do not need to define this column in their translation classes, and I see it is defined in \XLite\Model\Base\Translation. Why does this method work for other modules and not this one?

Ksenia 04-06-2014 11:41 AM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Hi Mike!

Thank you for posting your findings here. I think Tony does monitor it. I'm also resending the notifications to him, so he has no chance to miss them=) I guess he might be overloaded now, as after the webinar he leaves for vacations. But tomorrow I'll try to take's Tony hand, show the thread and make sure he react properly.

totaltec 04-06-2014 04:05 PM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Thanks Ksenia!

Tony,
I solved the problem (thankfully I was stuck for hours!), but I would still like an explanation of why this works. I found that by modifying XLite\Module\Tony\News\Model\News.php and changing the line:
Code:

class News extends \XLite\Model\AEntity
To:
Code:

class News extends \XLite\Model\Base\I18n
Fixes the error that it was throwing, and the table "xc_news_translations" is successfully created. The functioning of the module appears unchanged besides that.

What is the difference here, and why should we ever use "\XLite\Model\AEntity" if it cannot be translated?

tony_sologubov 04-07-2014 03:34 AM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Quote:

Originally Posted by totaltec
Running the script within the xcart directory the correct usage was:
..\..\php\php.exe ../next-sdk/devkit/macros/create-module.php --module=Tony\News --version=5.0

Note that using --module=Tony\\News caused an error. May be a quirk related to Windows only


Thanks for spotting it out! I will cover it when I write an article about our SDK.

tony_sologubov 04-07-2014 03:43 AM

Re: Webinar for X-Cart 5 developers on March,18th.
 
Thank you Mike for spotting a mistake! I just corrected it.

As for breadcrumbs, this is perfect that you learned it. The thing about X-Cart 5 code is that it is quite terse. You define a single method and voila breadcrumbs appear.

Quote:

Originally Posted by totaltec
Found time to finish working through the tutorial. There is a typo in this section:
"Update controller
Edit the classes/XLite/Module/Tony/News/View/Model/NewsEdit.php file and add the following code there:"

The file path is wrong, it should be:
"classes/XLite/Module/Tony/News/Controller/Admin/NewsEdit.php"

Also, I added this code to the News controller in classes/XLite/Module/Tony/News/Controller/Customer/NewsEdit.php:
Code:

        public function getNewsTitle()
        {
            $id = intval(\XLite\Core\Request::getInstance()->news_id);
 
 
            $return = '';
 
 
            if ($id != 0)
            {
                $news = \XLite\Core\Database::getRepo('XLite\Module\Tony\News\Model\News')->find($id);
 
                if ($news) {
                    $return = $news->getTitle();
                }
            }
 
 
            return $return;
        }

    /**
    * Return the current page title (for the content area)
    *
    * @return string
    */
    public function getTitle()
    {
        return 'News';
    }

    /**
    * Common method to determine current location
    *
    * @return string
    */
    protected function getLocation()
    {
        return $this->getTitle();
    }

This allowed the section name "News" to be displayed in the bread crumb area and the page title. It also allowed me to use the function getNewsTitle() to display the title on the news page in the customer area after adding the following code to skins/default/en/modules/Tony/News/page/news/body.tpl
Code:

<h2>{getNewsTitle():h}</h2>

Thanks again for this learning experience, I feel much better about XC5 and my own ability to work with it.



All times are GMT -8. The time now is 12:11 PM.

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