-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Mod sample data #7680
[RFC] Mod sample data #7680
Conversation
👍 very very good idea 😉 |
Tested. Maybe should be considered :
|
Yeah, I noticed that already soemtime ago. I need to fix that JavaScript there so it properly terminates and doesn't try to load the next step 😄
I was thinking about best approach with the home. Currently I create a new "main menu" and set the the existing "home" to a regular menuitem and create a new home from sampledata. This is something that could be improved I guess.
I had that thought as well, but haven't figured out a sane way to do it. Also I could see that an extension could potentially provide its own sampledata set which can be installed with this.
Here it gets very tricky. Currently I store the inserted IDs in the session so I can use it later when I need to link eg an article to a menu item. After you close the browser, Joomla doesn't know anymore which content comes from the sampledata. Thus uninstalling it is not possible easily.
Any ideas on implementation? 👍 |
Sorry, none. I see how useful it can be for a 3rd party extension once the extension is installed, but I see also all the possible failures. |
It isn't really dangerous as it doesn't delete anything. It just adds data and modules. The only thing that is changed is the default "home" menuitem. Which is simple to switch back and we could also remove that from the sampledata if we want. |
couple notes before I forget 😄 use And maybe we do not need
maybe can save this ids as parameters in related plugin, somehowe ... then it solwe will try test this evening, |
I like the idea - the only problem is when someone installs one set of sample data on top of another set or even worse on top of their own content. If you want to do it post-install like this then I would suggest the only way to do it properly is to remove all existing content before installing the sample content - obviously with plenty of warnings This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7680. |
I made this intential this way. So multiple plugins could run on the same step if wanted. Again thinking about 3rd party plugins which "hook" into eg the testing sampledata.
The requests go through com_ajax. So using
I need that mainly for the progress bar, so I know how big steps to draw. The other things could indeed be done without having that step property.
That would be a (quite hacky) idea. You would have to make sure they don't get overwritten when one saves the plugin. And it would need code again to delete the items using the models/tables. I wouldn't want to use direct queries there so we don't have to deal with nested sets, asset tracking and the like.
That would be awesome. It's definitively not my strongest area. I was glad it actually worked 😆 |
Usually, installing two sets will fail due to already existing alias. I can solve that by automatically generate a new alias till it sticks, but I haven't seen the need yet.
I would never remove existing content. Even after 15 confirmation boxes I'm sure some users would accidentally delete the content. YCFS and I don't want to confirm that 😄 |
Sorry, then seems I wrong understand this part of the idea. I thought that each extension (component) can have separated plugin, that can be installed separately, and each this plugin can provide own data collection (sorry for my English 😄 ) and
So you can install
true, but each plugin can have hidden fields that keep the list of ids: so if you need get access to these values you just do yes, it still hacky ... but also I think that it not so bad 😄 |
You didn't understand wrong. It's both variants which should work (in theory).
I think I like that idea. |
I presume these plugins are going to be core-supported (we can package them up into the full install packs) - but we once people are done with them then they need to be uninstallable and not reappearing on updates? |
Good point. We could of course make them installable as a package without it being included in core, but that kind of is counterproductive for the sampledata. Doesn't make sense I guess. Not sure what the best approach is here and how it can be handled. |
I'm hoping this module will make it in the final 3.5 release. This will really (like really) come in handy for third party vendors. The question that I hear over and over again from my customers is if they can install sample data on an existing Joomla site with data and for me this will be a relief to know now it's possible. Kudos Bakual :) This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/7680. |
It will certainly not be in 3.5. |
@Bakual i din't know about this PR until you pointed. Thanks. |
Kind of, yes. |
ok then. will wait. |
I have tested this item 🔴 unsuccessfully on 9e2d6ac Deactivating one of the plugins changed the possible sample data to install. Could not revered the patch This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/7680. |
Is this still scheduled for 3.7.0? |
I haven't heard about webservices for some time. Maybe @rdeutz and @chrisdavenport know the current state and what should be done here. |
I have now updated this PR with latest staging and it should work again. It needs still a lot of work but since Webservices doesn't seem to gain much traction lately I thought it may be worth to revisit this approach. |
I've now fixed the asset issue you mentioned and I changed the access level so it's only visible to the super users. I think I need to add the CSRF tokens to the module and plugins. If you merge it before I get to do that, I can do it also in a separate PR. @matrikular raised the question if it should live in a different place (eg installer) instead of a module in the cPanel. However I doubt I have the time to change that. So that would have to be done by someone else if you guys also think the cPanel is the wrong place. I haven't done anything for people updating. Not sure what we should do there. Add the module/plugins to the #__extensions table but unpublished? The module certainly shouldn't show up for existing sites. |
That'd probably be a good idea. We shouldn't put an extension onto a site that isn't properly installed, so without that it'd be sitting in abyss and people hitting discover would stumble upon it that way. |
@@ -1476,9 +1480,10 @@ INSERT INTO "#__modules" ("id", "asset_id", "title", "note", "content", "orderin | |||
(16, 50, 'Login Form', '', '', 7, 'position-7', 0, '1970-01-01 00:00:00', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 1, 'mod_login', 1, 1, '{"greeting":"1","name":"0"}', 0, '*'), | |||
(17, 51, 'Breadcrumbs', '', '', 1, 'position-2', 0, '1970-01-01 00:00:00', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 1, 'mod_breadcrumbs', 1, 1, '{"moduleclass_sfx":"","showHome":"1","homeText":"","showComponent":"1","separator":"","cache":"0","cache_time":"0","cachemode":"itemid"}', 0, '*'), | |||
(79, 52, 'Multilanguage status', '', '', 1, 'status', 0, '1970-01-01 00:00:00', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 0, 'mod_multilangstatus', 3, 1, '{"layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'), | |||
(86, 53, 'Joomla Version', '', '', 1, 'footer', 0, '1970-01-01 00:00:00', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 1, 'mod_version', 3, 1, '{"format":"short","product":"1","layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'); | |||
(86, 53, 'Joomla Version', '', '', 1, 'footer', 0, '1970-01-01 00:00:00', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 1, 'mod_version', 3, 1, '{"format":"short","product":"1","layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'), | |||
(87, 55, 'Sample Data', '', '', 0, 'cpanel', 0, '1970-01-01 00:00:00', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 1, 'mod_sampledata', 3, 1, '{}', 1, '*'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You didn't do the access level change for the non-MySQL databases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aw right. I did the lft/rgt stuff but forgot the viewlevel. Will do this evening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Will add the update SQLs this evening so the plugins and module are installed but unpublished. |
Added the update SQL files which will install the module and the two plugins as unpublished extensions. |
Nice work @Bakual 👍 👍 |
versions and date, including copyright, need correcting |
The only thing that needs to be manually corrected is version tags and dates in the new extension manifests. The version bump script will take care of version placeholders and copyright headers. |
Tested and commented #17415 |
I've just read about this feature in the article about beta of 3.8 at the joomla.org and it looks like a nice addition. I've looked quickly at the code and I think that I missed something obvious - how do I build own sample data for the whole site with this approach? Do I need to build the sample data plugin by hand? At the moment I can prepare a QuickStart installation package with own sample data by exporting and adjusting SQL dump file in a matter of minutes. If option to install sample data will be removed from installation, with this approach I will need weeks? to create that kind of plugin for scratch. It is a nice addition to install some sample data for a single extension after installation, but not for the whole site. In this case some kind of feature to import/export content would be great. I haven't looked closely at the whole code yet, so I'm sorry, but I must missed something obvious, how do I build own sample data for the whole site with this approach if installation of SQL dump will be removed from installation? |
You need to write your own plugin if you want to have a different sample data set. For core, the intention was to get rid of those SQL files because we had to always do three sets of them for the various databases we support. Also there was always errors in them (eg wrong assets and the like). That's why I use the respective models and tables so i don't have to deal with the stuff Joomla can handle itself. |
@Bakual, Thank you for your reply.
What I want to do - I want to build a QuickStart package, this is an additional, optional installation type of Joomla! provided by most, if not by all template providers. The name varies by different providers, for example Gavick call it a QuickStart package, RocketTheme call this a RocketLauncher ... Basically, it is a modified, complete installation package of Joomla!, that contains files of third party extensions and own SQL sample data, that are used during installation. After that kind of installation, client get's an exact copy of the demo site, that already has all used extensions, content and settings as in the demo site of the template. Basic advantage of this type of installation was, that client didn't had to install everything by hand, and tries to recreate content of demo site, or guess what settings were used. Of course this was intended only for new installs, because there was no offical way to import content in existing site. Currently it was quite easy to build that kind of package, as you just needed to have a modified package with all additional files + own modified SQL sample data file. Option to install sample data after installation is great (and I do understand that is a better way to handle that part of installation for the core) and it opens a new ways for developers, but if this possibility will disapear in 3.8, this may cause a lot of problems for the template providers. I didn't have time to review the code yet but thanks for the tips! Does decision to remove import of sample data during installation in 3.8 was alrady made? In beta I still see it in place? Once again thank you for your reply. |
It will stay in place through the rest of the 3.x releases. We are looking at removing the sample data SQL files for 4.0 though. Even if those do go away, you'd still have a couple of options for using Joomla's native web installer to create a quick start package:
Another thing to keep in mind is with the plugin approach, you wouldn't have to build and distribute a customized Joomla distribution. It might take some extra steps for end users, but as a distributor/packager it may be easier to use the plugin approach and advise users to install your sample data plugin which creates the same end result as your fully packaged quick start (instead of having to synchronize the entire package with each release, your plugin has the instructions in it to install the extra extensions, load the data, etc.). |
* staging: (148 commits) Correcting non-escaped double quotes in en-GB.plg_sampledata_testing.ini (joomla#17455) Correct namespace reference (Fix joomla#17448) Correcting Jalali/Persian calendar popup (joomla#17432) Adding russian calendar language file (joomla#17443) Reset for dev Prepare 3.8 Beta release Fix covers tags Fix file paths Move library files to just libraries/src as it should be (joomla#17441) Add a default empty array for the session queue (joomla#16943) [3.8] Restructure version constants (joomla#16169) Adjusting copyright and versions and two remaining "sampledata" (joomla#17435) PHP 7.2 has branched, update Travis config to reflect PHP 7.2 count warning (joomla#16840) Enforce array for subform values (joomla#16733) System URL menu link (joomla#17419) Don't use array merge here. (joomla#17391) add the checked attribute (joomla#17336) [RFC] Mod sample data (joomla#7680) Rename Page to Menu Item (joomla#17409) ...
Great to hear that! I was worried that 3.8 will bring some biger changes without any prior notice. Yes, I see many possibilities and advantages here, so I'm happy to see such a feature available in the core. Overall process could be simplified for both sides and what is more important not limited only to the new installs. Thanks guys for your replies and for the contribution! |
* staging: (148 commits) Correcting non-escaped double quotes in en-GB.plg_sampledata_testing.ini (joomla#17455) Correct namespace reference (Fix joomla#17448) Correcting Jalali/Persian calendar popup (joomla#17432) Adding russian calendar language file (joomla#17443) Reset for dev Prepare 3.8 Beta release Fix covers tags Fix file paths Move library files to just libraries/src as it should be (joomla#17441) Add a default empty array for the session queue (joomla#16943) [3.8] Restructure version constants (joomla#16169) Adjusting copyright and versions and two remaining "sampledata" (joomla#17435) PHP 7.2 has branched, update Travis config to reflect PHP 7.2 count warning (joomla#16840) Enforce array for subform values (joomla#16733) System URL menu link (joomla#17419) Don't use array merge here. (joomla#17391) add the checked attribute (joomla#17336) [RFC] Mod sample data (joomla#7680) Rename Page to Menu Item (joomla#17409) ...
Hi :3 Thanks everybody for your just amazing effort and results. I just installed Joomla 3.8.0 by the cpanel softacolous script. The only choice I happen to receive as I login the admin panel, is "Blog sample data". I checked the plugins, and the blog sample plugin is the only one installed. What could I do to try and set other sample data plugins ? I would love to install the testing one. Sorry for bothering you here :3 |
The testing sample data is not distributed with Joomla - it is only for testing during the development process |
Well, I probably misdefined. I talk about the "install all modules and menus" sample data set. |
There is the testing sampledata plugin which can be found here: https://github.com/joomla-extensions/testing-sample-data/releases Other than that, there are no other plugins from core. But I'd expect more such plugins to come, especially from template provides as part of their bundles. |
Thank you everybody for your very kind help :3 |
Issue
Currently we handle our sample data with plain SQL queries that are applied.
Managing those queries became quite complex over time. Due to the way they are set up (they replace the tables, not just add to it), it also became complex to add new extensions to core since you need to add them in the sample data as well.
Also the sampledata currently can't handle extensions which we decoupled from core (eg Weblinks). We had to remove the sampledata associated to it.
Proposed Solution
This PR adds a new module and some plugins which lets you install the sampledata after the installation is done. It will show up in the administrator control panel.
![sampledata](https://cloud.githubusercontent.com/assets/1018684/9192957/e807e5da-400f-11e5-9b39-233503462139.PNG)
![plugins](https://cloud.githubusercontent.com/assets/1018684/9192971/078d6542-4010-11e5-9fd3-5d6a04276eea.PNG)
![progress](https://cloud.githubusercontent.com/assets/1018684/9193020/7c41b244-4010-11e5-8fa9-0338f8d7d4e3.PNG)
The sampledata itself is handled by a plugin. Which means in theory they could also be provided by 3rd parties.
When the user activates one of the links in the module, it will fire some AJAX request which will install the chosen sampledata set. It does this in multiple steps and shows the progress while doing so.
Background
require_once
which failed when the model was called outside of com_menus. I changed the call to JLoader so the class gets autoloaded if needed. In the plugin is also register the same class with the correct path, and thus JLoader will find it. That's the only needed change outside the sampledata extensions.Testing
You can test this by applying this PR and then discover and install the module and plugins.
You can also download my branch and install the CMS fresh, then the module and plugins should already be installed and visible.
Make sure you try on a system with no sampledata already installed, otherwise it may very well clash with the existing data.
Known Limitations
Request For Comments
I would be very happy if someone could look over this implementation. I'm quite sure there are ways to improve it.