We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    IMO, the best way to handle this is to go ahead and overwrite it (after all, you might want to fix a bug in the CSS or add new CSS code in the future).

    Create a property (parameter) called &cssPath and use that in the code along with $modx->regClientCSS() to insert the CSS file. That way, the user can duplicate and rename the CSS file and specify the path to their copy in the parameters to avoid their changes being overwritten.

    FWIW, I’m working on a monster generic/example build package that shows how to do almost everything you might want to do (with variables to turn options on and off). I haven’t decided what to call it. I’m hoping to have it up at GitHub soon.
      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
      • 34120
      • 236 Posts
      Hi Bob,
      Thanks for the reply. I want to create the following directory and file: assets/css/main.css

      This would be the main CSS file for the site, It could initially be blank or may contain some basic example styles. That’s why I don’t want to overwrite because it’s where all the custom styling would be added. It’s being lazy really just to avoid having to manually create the file. I’ve got another CSS file in the package: assets/components/comp-name/css/base.css this contains css reset styles etc. This is overwritten when the package is updated so I can make any updates here.

      That’s the idea anyway, hope it makes sense.

      Will keep an eye out for the monster smiley sounds interesting.
        • 34120
        • 236 Posts
        Had a bit of a rework, I’ve done away with creating the css directory and main.css file automatically. When testing this live it was causing problems. Because these files were being created by MODx the file ownership was set to nobody/nobody meaning I couldn’t write to the directory or edit the files.

        I’ve now moved on to a new issue: In my main template I want to use a chunk for the footer eg. [[$footerContent]] footer content would be added to this chunk, therefore I don’t want to overwrite it when updating the package. I’m not sure how to go about this or maybe there is an alternative method.

        I’m wondering if I’m in the right area here, the following code is taken form data/transport.chunks.php. Can anyone tell me what the ’true,true’ at the end of the code does?
        $chunks[4]= $modx->newObject('modChunk');
        $chunks[4]->fromArray(array(
            'id' => 4,
            'name' => 'footerContent',
            'description' => 'Footer content holder',
            'snippet' => file_get_contents($sources['source_core'].'/elements/chunks/footerContent.chunk.tpl'),
            'properties' => '',
        ),'',true,true);



        Many thanks
          • 3749
          • 24,544 Posts
          From my as-yet imaginary book:

          fromArray (array $fldarray,
          [string $keyPrefix = ’’],
          [boolean $setPrimaryKeys = false],
          [boolean $rawValues = false],
          [boolean $adhocValues = false])

          Sets object fields from an associative array. $keyPrefix is an optional prefix that will be stripped from all fields. The other fields are seldom used except in MODx internal code and transport packages.

          In your case, you’d probably want $rawValues = true, and setPrimaryKeys = true.

          Again, with respect to overwriting, the usual method is to overwrite on upgrade, use a property (parameter) to specify the name of the chunk, and encourage the user to duplicate, rename, and specify the duplicate in the tag if they need to modify the chunk.

          If you’re determined not to overwrite them, you can set UPDATE_OBJECT to false in the attributes array in build.transport.php, or you can install the chunk(s) only in the INSTALL portion of a PHP resolver.

          BTW, a preliminary version of MyComponent (the monster, tour-de-force build script) is up at GitHub: https://github.com/BobRay/MyComponent. It has lots of examples for installing just about anything there is (except custom DB tables).
            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
            • 34120
            • 236 Posts
            Thanks again Bob, a bit to get my head around there, I’ll check it out tomorrow.

            Again, with respect to overwriting, the usual method is to overwrite on upgrade
            I think I need to get into this way of thinking, it would probably make my life easier smiley I’m not really familiar with properties yet so a few things to try out.

            I’ll be checking out your component too!

            Cheers
              • 3749
              • 24,544 Posts
              Quote from: rf9 at Feb 07, 2011, 06:54 PM

              I think I need to get into this way of thinking, it would probably make my life easier smiley I’m not really familiar with properties yet so a few things to try out.
              If you’ve used snippet parameters, you should have some idea because those are properties. So, for example the &tpl (parameter) property of getResources sets the name of the Tpl chunk used to format items.


              I’ll be checking out your component too!

              Bear in mind that it’s not officially out yet and is a work in progress. I hope to have a tutorial for it up soon.
                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
                • 34120
                • 236 Posts
                oops, yeah I’ve used properties/parameters, quite a bit, lol embarrassed
                Just not in relation to packages and build scripts.

                re: your component, I’m just interested to take a peek inside at this stage.

                ta
                  • 3749
                  • 24,544 Posts
                  It’s all here: GitHub: https://github.com/BobRay/MyComponent.

                  And the tutorial is here (along with some advice about building proper transport packages): http://bobsguides.com/mycomponent-tutorial.html
                    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