<![CDATA[ Boggled about the benefits of storing resources in the database - My Forums]]> https://forums.modx.com/thread/?thread=2883 <![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17904 http://rtfm.modx.com/display/revolution20/Roadmap]]> splittingred Sep 26, 2010, 04:12 PM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17904 <![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17903
edit :i deleted what was written about a snippet to do that, just understood that i need a plugin as ryan says.]]>
nyl auster Sep 26, 2010, 01:23 PM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17903
<![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17902
I suppose an improvement would be to create a plugin that automatically inserts an include statement into the text area whenever you create a new chunk/template/plugin, and stubs out a file on the filesystem in your preferred location. You could even have the same plugin hide the textarea itself and so it would appear as if the you were just loading the metadata.

You could then take it a step further and create a custom component that looked in your "Elements filesystem location" for files ending in .chunk.inc, .template.inc and so on, built a grid with any it found, and allowed you to "register" those filesystem based Elements into your MODx deployment. Again, not ideal, but definitely a decent workaround.

At least with MODx you can come up with creative methods that work to emulate other ways, without breaking the system or requiring custom hacks.]]>
rethrash Sep 26, 2010, 12:21 PM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17902
<![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17901
]]>
nyl auster Sep 26, 2010, 10:58 AM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17901
<![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17900
It would not be hard to implement facilities for files based chunks, but most of the components available use file based chunks only for the default chunks.

Generally speaking, i like to use similar function as above + an helper theme path.
When that is done, i can use de default chunks name, separated by directories (theme).

Like :
assets/templates/mytemplate/getresourceschunks/ and the get resources chunks in here
assets/templates/mytemplate/quipchunks/ and the quip chunks in here

It would be nice to have similar functionalities in all majors snippets by default.
But i think it’s a too light implementation for now, since it impose some directory structure and that is not the leimotiv of many MODxers.
I think that some imposed structures can sometimes help, and would allow quicker implementations of snippets with chunks without having to learn each snippets of doing things.]]>
lossendae Sep 26, 2010, 10:38 AM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17900
<![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17899 Ok i will try this code.
But it seems to work only if this is your OWN snippet, is it possible to to the same thing when i override a chunk from an existing snippet ? Let’s say i want to override the default tpl from quip, the normal way is to create a chunk via UI to set my own html (and call it in the snippet call). Do you know a way to put those chunks in file too ?]]>
nyl auster Sep 26, 2010, 10:24 AM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=4#dis-post-17899
<![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=3#dis-post-17898 I understand your concern.
What you ask for is on the roadmap.
If you can provide a good solution sooner, that will not break how things work for now, and contribute it back to the project, i’m sure that the team will gladly welcome your modifications.

@nyl
Put what you want to be file based into actual files and use some code to get it back from there before checking for db entries.
I don’t keep my chunks and snippets in the db in the database for the same reason as you don’t want to.

Example for chunks in Revo:

<?php
/**
	 * Creates a temporary modChunk object from a tpl file.
	 *
	 * @access private
	 * @param string $name The name of the chunk to load from file.
	 * @return modChunk The newly created modChunk object.
	 */
    private function _getDefaultTplChunk($name) {
        $chunk = false;
        $f = $this->config['chunks_path'].strtolower($name).'.html';
        if (file_exists($f)) {
            $o = file_get_contents($f);
            $chunk = $this->modx->newObject('modChunk');
            $chunk->set('name',$name);
            $chunk->setContent($o);
        }
        return $chunk;
    }


This code is taken straight from Quip and it was there in early alpha stage.

Maybe you can ask for an official API function from the Team. idk...]]>
lossendae Sep 26, 2010, 10:05 AM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=3#dis-post-17898
<![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=3#dis-post-17897
However, once the site is online, an operation like push changes from my localhost to production site is just what i have to do, like everybody else, when working on websites. It is not something i can avoid...

It’s easy when site content (documents for modx) are in database and configuration / templates / script are in files. I just have to upload new files to the production site.
But how can i do this if ALL is in database ? I have to write some sql scripts ? Is there components to help me doing that ?

]]>
nyl auster Sep 26, 2010, 09:46 AM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=3#dis-post-17897
<![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=3#dis-post-17896
@lossendae: The MODx team has answered me in the sense that my posts have been followed by theirs, but not in the sense that the balance of arguments would shift in favor of database storage. I have to refer to the summary post I made, listing all the points. Your second point about workarounds is included. Sure, I can use includes, but it comes with a price, and it’s a partial and poor solution.]]>
slikts Sep 26, 2010, 09:19 AM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=3#dis-post-17896
<![CDATA[Re: Boggled about the benefits of storing resources in the database]]> https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=3#dis-post-17895
I’m agree with your points.
However i’m looking for a alternative CMF or framework to Drupal, and the staging problematic is a very important one for me. (and Drupal needs a lot of improvements on this side, a lot of configuration is stucked in database)
I can’t help thinking that staging and redeployment are easier with files, which are easier to manipulate than database.]]>
nyl auster Sep 26, 2010, 08:45 AM https://forums.modx.com/thread/2883/boggled-about-the-benefits-of-storing-resources-in-the-database?page=3#dis-post-17895