We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32507
    • 142 Posts
    Hi,

    I purchased social stream PHP script from EnvatoMarket. The package is quite complicated with multiple directories & PHP files etc.
    I just installed the package to Assets/Components as it is. After that i created Resource (html) with snippet call where is reguired code to create new social stream instance. Naturally i changed all init.php links to point to MODX Assets/components directory.

    It works. Sort of...it's unstable and does weird things. I contacted to plugin provider support and everything should be okay at their part. I quess there's something wrong, how i have (tried) to integrate the plugin.

    How third party plugins should be integrated to MODX the right way? Or is possible at all (with relatively little effort & PHP knowledge)?

    Thanks!
      • 3749
      • 24,544 Posts
      It really depends on the package. A simple package that just does something and displays a results message can be very simple, but most packages interact with the user in complex ways and porting them to MODX can be very complex.

      Is there an index.php file in the root of the package? If so, you might try replacing your snippet code with a single include statement for that file. It may not work, but it's worth a shot.

      Another thing to try would be to watch the console tab in Chrome Dev tools (Ctrl-shift-i) to see if JavaScript errors are causing the instability
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 32507
        • 142 Posts
        Thanks,
        No errors on console. But as said, plugin itself is quite complicated and MODX is complicated too smiley

        JSONDerulo extra is closest solution, but it doesn't offer out of box solution for my customers needs and i'm unable to customize it.

        So in this case I give up. This is too much for my developer skills sad
        I may have to use some "turnkey solution" (= WordPress) sad

        Thanks.
          • 3749
          • 24,544 Posts
          Did you try this?
          Is there an index.php file in the root of the package? If so, you might try replacing your snippet code with a single include statement for that file. It may not work, but it's worth a shot.
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 32507
            • 142 Posts
            Yes i tried, but no luck.
              • 3749
              • 24,544 Posts
              Looking at the Installation section of the Social Stream docs, it looks like it assumes that you can put PHP code anywhere on your site and have it execute. In MODX, PHP code in a resource will not execute, so you'd have to convert all those separate PHP code examples to separate snippets and put a snippet tag on the page (or in the case of the first one, at the top of all Templates).

              It does look like it should work, though. Notice that I've removed the PHP opening and closing tags.

              Edit the Social Stream config file as described in the docs.

              Put this as the very first line of all templates for pages that will display Social Stream stuff:

              [[IncludeSocialStream]]


              Create a snippet called IncludeSocialStream, with this single line of code (assumes that the social-stream.php file is at assets/components/social-stream/social-stream.php):

              require_once MODX_ASSETS_PATH .  'components/social-stream/social-stream.php'; // Path to PHP Social Stream main file


              Create another snippet called SocialStream with this code (notice that 'echo' has been replaced with 'return'):

              return social_stream(
                      array(
                          'id' => '1',
                          'type' => 'wall',
                          'network' => array(
                              'facebook' => array(
                                  'facebook_id_1' => array(
                                      '624290390999239' // Replace with your Facebook page ID
                                  ),
                                  'facebook_pagefeed' => 'posts'
                              ),
                              'twitter' => array(
                                  'twitter_id_1' => array(
                                      'mashable' // Replace with your Twitter username
                                  ),
                                  'twitter_images' => 'small',
                                  'twitter_feeds' => 'retweets,replies'
                              ),
                              'google' => array(
                                  'google_id_1' => array(
                                      '112592709425670873637' // Replace with your Google+ profile ID
                                  )
                              ),
                              'tumblr' => array(
                                  'tumblr_id_1' => array(
                                      'ghostphotographs' // Replace with your Tumblr username
                                  )
                              ),
                              'pinterest' => array(
                                  'pinterest_id_1' => array(
                                      '2013TopPins' // Replace with your Pinterest username
                                  )
                              )
                          ),
                          'theme' => 'sb-modern-light',
                          'itemwidth' => 250,
                          'results' => 30,
                          'debuglog' => 0,
                          'add_files' => true
                      )
                  );



              Put this tag where you want the output:

              [[!SocialStream]]
              [ed. note: BobRay last edited this post 6 years, 6 months ago.]
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 32507
                • 142 Posts
                Hi, This works better. There's still some inconsistencies, but it could be javascript related?
                When SocialStrean tag is uncached it works on pageload, but gives error after page refresh. So i made it uncached.(?)
                [[SocialStream]]


                Thanks for Your effort & help.
                  • 3749
                  • 24,544 Posts
                  If you turn on Chrome Dev. Tools (Ctrl-shift-i) or do the same command in Firefox, it will show you any JavaScript errors on the Console tab when the page loads.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting