Is there a way to convert to Scrapbook to Stack?

Permalink 2 users found helpful
So the stack feature looks awesome. It's just that I have a ton of stuff in scrapbooks. I was looking for a way to go into my scrapbook and click "copy to stack" or something.

An easy way to convert to stacks so I can start using those.

Or am I missing something?

Thanks!

dibbc
 
vipahhh replied on at Permalink Reply
I'm looking for the same function!
iLP replied on at Permalink Reply
iLP
Indeed. I have recently upgraded to 5.5, and now I have a bunch of individual content blocks that I cannot change en masse as before, and must now edit each one individually. The only other option I see is to copy one to the clipboard, and then create a new stack that I then replace for each instance of the prior scrapbook block, which is actually more work up front, but will be editable en masse going forward from there. A method of converting all the existing scrapbook blocks would make much more sense.
CommotionCreative replied on at Permalink Reply
CommotionCreative
Same problem here.
KenHarvestClouds replied on at Permalink Reply
KenHarvestClouds
Bump! Same thing! Good thing I don't have a ton of them!
tciweb replied on at Permalink Reply
Same issue here, can someone please tell us how to migrate?!
jordanlev replied on at Permalink Reply
jordanlev
This is UNTESTED and I am not sure if it will work, but you might want to try this ON A TEST SITE (do **NOT** attempt this on your production site -- it is completely UNTESTED and might make your computer blow up and your website disappear from the fabric of the universe). Really, seriously, do not use this on your real site. Make a copy of your site and try it out on the copy (and make this copy on your local computer, and make double-triple-quadruple sure you're using this on a site that you don't care about -- like if the whole thing crashes and is totally unrecoverable you're okay with that).

Okay...

Create a new file called "scrapbookconvert.php" in the test site's top-level "tools" directory, and paste this code in there:
<?php defined('C5_EXECUTE') or die("Access Denied.");
$sbh = Loader::helper('concrete/scrapbook');
$scrapbookPage = $sbh->getGlobalScrapbookPage();
if (!$scrapbookPage->getCollectionID()) {
   die('ERROR: NO SCRAPBOOK PAGE FOUND');
}
$scrapbooks = $sbh->getAvailableScrapbooks();
foreach ($scrapbooks as $sb) {
   $arHandle = $sb['arHandle'];
   $scrapbookArea = new Area($arHandle);
   $scrapbookBlocks = $scrapbookArea->getAreaBlocksArray($scrapbookPage);
   $success = addBlocksToNewStack($arHandle, $scrapbookBlocks, $scrapbookPage);
   echo "Scrapbook: {$arHandle} - " . ($success ? 'successfully converted to stack' : 'failed (stack already exists with that name)') . ".\n";
}
echo "done.";

Then navigate to this url:
http://yourTESTdomainname-do-not-run-this-on-a-real-site.com/index.php/tools/scrapbookconvert.php


It probably won't work. It will probably break everything (well, it probably won't, but just in case... make sure you **ONLY** run this on a test site that you don't care about).

But maybe it might possibly work, and that would be cool.

-Jordan
jero replied on at Permalink Reply
jero
I've run this on a test system and found a couple of problems:

1) I am running PHP 5.2.4, and I get a fatal error:

func_get_args(): Can't be used as a function parameter in concrete/libraries/item_list.php on line 515


Not an issue with PHP 5.3, but perhaps a bit hard on those with older systems (Ubuntu 8.04LTS), especially as the system requirements lists 5.2 as required.

Easy enough to fix by pulling into an array first.

However, I get stacks created, but nothing in them.
jordanlev replied on at Permalink Reply
jordanlev
jmcgarvey replied on at Permalink Reply
jmcgarvey
I ran this script and it reported success, did not get any errors... but there are no Stacks created. Any ideas?
jordanlev replied on at Permalink Reply
jordanlev
None -- sorry. I unfortunately don't have the bandwidth to look at this in the near future -- hopefully someone else can take a look.
BHWW replied on at Permalink Reply
BHWW
Thanks Jordan

I get this error if that helps..

Fatal error: Call to undefined function addBlocksToNewStack() in /Applications/MAMP/htdocs/www.****.com/tools/scrapbookconvert.php on line 12
jero replied on at Permalink Reply
jero
You've missed part of the code - there's more there than you can see. Click the "view entire block" link - the little one in blue on the bottom right.
hereNT replied on at Permalink Reply
hereNT
I tried it with the full code on a 5.5.2.1 site and it made the scrapbook but didn't copy any of the blocks. Any ideas what was wrong?
skote replied on at Permalink Reply
I just updated a large site (800+ pages) to 5.5.2.1 from 5.4.2.2. This site had 50 items in the scrapbook, applying across thousands of instances. This is the migration script I used. It takes each block in the scrapbook, copies it into its own stack, then replaces all instances of the original block with a proxy block pointing to the new stack. Basically, you end up with a lot of one-block stacks that mirror what you had in the scrapbook.
There still may be a few gaps and YMMV, but enjoy. Don't forget to copy from the whole code block, not just what's shown initially.


<?php defined('C5_EXECUTE') or die("Access Denied."); ?>
<h1>Migrating Scrapbook Content to Stacks.</h1>
<p>START</p>
<?php
// Config. Delete the original blocks in the scrapbook?
$deleteOriginals = true;
// Empty the cache so we don't get any weird errors
Cache::flush();
$db = Loader::db();
Loader::model('stack/model');
$scrapbookHelper = Loader::helper('concrete/scrapbook');
$globalScrapbookPage = $scrapbookHelper->getGlobalScrapbookPage();
if (!$globalScrapbookPage->getCollectionID()) {
   die('Error: No scrapbook page found.');
}
malkau replied on at Permalink Reply
malkau
Hello

Thanks for posting this... how do I use this code?

Paste it to a file then put it where?

Thanks!
jordanlev replied on at Permalink Reply
jordanlev
Note that I didn't write that code and I have absolutely no clue if it works or not (and if it doesn't work then unfortunately I am not capable of helping fix it).

BUT, here is I think the easiest way to get this code running in your site:

1) Create a new file called "scrapbook_to_stacks.php" in your site's top-level "single_pages" directory (*not* in concrete/single_pages).

2) Paste the above code into that file

3) Log into your site and go to Dashboard > Pages & Themes > Single Pages

4) In the textbox for adding new single pages, enter "scrapbook_to_stacks" (without the quotes), and click the "Add" button

5) **VERY IMPORTANT** MAKE SURE YOU HAVE BACKED UP YOUR SITE'S DATABASE FIRST!! If the above code does not work, it might totally mess up your system and you'd have no way to get it back!

6) **MAKE SURE YOU BACKED UP YOUR DATABSE BEFORE PROCEEDING** I'm serious here, do not run that code without backing up your site's database first (via Dashboard > System & Settings > Backup & Restore > Backup Database).

7) Assuming you backed up your database, now navigate to that new single_page:
http://yoursite.com/scrapbook_to_stacks...

8) IMPORTANT: After you're done with this, *DELETE* that single_page, otherwise anyone who stumbles upon that URL will trigger the code!! If you want to keep it around for some reason (which you really really shouldn't), at leasat set permissions on that page so that only the administrator can view it!

Best of luck.

-Jordan
skote replied on at Permalink Reply
Save it to a file called scrapbook_migration.php and put that in your
/webroot/tools/
folder. Then run the file by accessing
http://yoursite.com/tools/scrapbook_migration


And be sure to backup everything before you do this in case something doesn't work.
kevinla replied on at Permalink Reply
Worked perfectly! Wasn't sure if it worked or not because the script prints START END. But indeed it worked beautifully. I had about 5 simple html entries in my scrapbook and they were all converted to Stacks perfectly. Thanks again!
colin4255 replied on at Permalink Reply
colin4255
Tried this. Just got the message 'access denied' when I tried to run it. Didn't work for me. I even set Chmod to read, write, execute, but made no difference.
colin4255 replied on at Permalink Reply
colin4255
Out of interest, I tried doing it Jordanlev's way too. In this instance, it wouldn't even let me log in as admin. Well, it did, but I was unable to see anything from the admin , dashboard, or backend menus until I went into the site via ftp and deleted the file I had put where he suiggested to try and make it work or run the update.

It is just a real shame the C5 team didn't make this idea work when they published the upgrade. What use is preserving scrapbooks if there is no actal way to use them any more when editing a site page. Seems completley daft to me. Hours of work ahead I fear, and for no good reason.
kevllar replied on at Permalink Reply
kevllar
Can you provide more background info? Server type? Linux? Windows? Do you have .htaccess files denying access to folders?? I'm no expert but it did work for me perhaps I can help.
colin4255 replied on at Permalink Reply 1 Attachment
colin4255
Server is Linux based . Attached info with.htaccess file . Never had an issue like this with anything else I have tried to run, including C5 upgrades and installations
kevllar replied on at Permalink Reply
kevllar
It appears I'm getting the same error as you now. It's no longer working for me. Perhaps it has to do with version 5.6.0.2. I noticed you're on the same version. Sorry bout that mate.
colin4255 replied on at Permalink Reply
colin4255
No problem. Thanks for offering to help
invision replied on at Permalink Reply
invision
I have many sites built in C5 that make extensive use of scrapbooks to allow the end users the ability to re-use objects (like pre-configured menus, or repeating scraps of text, or logos) throughout the site.

WHY would you completely change software like this without having a migration path?
colin4255 replied on at Permalink Reply
colin4255
That is a very good question that no one seems to want to answer, or provide a proper way around.

I have said many times, the people who use the C5 sites I design are not programmers and have wish to be. They just want to use the thing. Taking away from them something that works and replacing it with something they cannot use unless they begin all over again when they are supposed to be 'upgrading their software' makes no sense to regular users - or me either for that matter.

There should really have been a migration path. Right now, there isn't. You can see your old scrapbooks in the new versions, but you cannot actually use anything in them when in page edit mode. Nor can you convert them into stacks. Only current solution is to start all over again, especially if you upgrade to version 5.6.0.2.
skote replied on at Permalink Reply
I understand and agree with the frustration of having a core feature taken away. It was not a wise thing for the Core team to move to stacks without providing a migration path. This irritated me quite a lot and forced me to provide my own migration solution for my clients.

BUT, for the life of me, I don't understand the griping about it and the hopelessness people feel about it. This is open source software. If it doesn't do what you want, open up the source and change it yourself.

I provided a solution (above in this thread) that works when migrating to 5.5.2.1. Apparently it doesn't work with 5.6. So if you have an old site, migrate it to that version first, use my script, then upgrade to the latest afterward. Or if you're already on 5.6, do some debugging on my script to see where it fails and then fix it. There are comments inline explaining what it's supposed to be doing.

If you don't have the programming skills to do this, then hire someone who does. Do what it takes to get it working for your clients and then move on.
colin4255 replied on at Permalink Reply
colin4255
I agree that anyone who was a developer could open up the core and do just that, but a lot of us simply either don't known how, or don't have the skill level to get that clever. Now while that is very selfish of us I know, Concrete 5 is becoming a victim of its own success here and the core team need to be aware that more and more people are just users, not developers and as such, need a way to thread everything together that doesn't involve learning to re-invent the wheel every time you make a major upgrade.

You effectivley have a new car here but to some users it looks like you have taken away the wheels. You can't really offer this to everyone and then expect they will all be as clever as you are. That almost never happens.

Not too many years back I was working for an auto insurers when one day a woman called to ask if we could insure her car. I asked her what type it was and she simply said "It's a blue one". Those same people are now using computers. I may well be one of them.
jordanlev replied on at Permalink Reply
jordanlev
Honestly, I *never* upgrade a site once it's live. I consider the site that I build and deliver to clients to be the site, at its current version, and that's it. I don't promise a platform that gets updated all the time no matter what, I just promise it as it is when delivered.

So I know this doesn't really solve the problem (and I agree that the migration to 5.5 could have been handled much better by the core team), but you might want to consider just leaving sites that you've built at the version they're at.
colin4255 replied on at Permalink Reply
colin4255
That is what I have done with the rest of them It's just two clients wanted to have the latest thing - you know how people are.
invision replied on at Permalink Reply
invision
The challenge with not upgrading sites is that often exploits are found in old versions of software that are fixed by upgrading, allowing the hackers in... It's happened to me with Magento and with some other open source website stuff, so I try to keep everything reasonably updated.
colin4255 replied on at Permalink Reply
colin4255
And then clients see new add-on's that only work with the latest versions (that is what happened in my case). While I am not a lover of upgrading stuff for the sake of it, users don't see it that way and always want what is shiny and new. And I agree with you, many upgrades also include improvements in security too which is a serious consideration when deciding whether to upgrade.

This is by no means a problem confined only to C5 - Wordpress and Joomla have done similar things in the past too.

My problem is that I love C5, I find it easy to deploy and change the look of (the very first CMS that is actually really easy to change the look of in faceven if you have no developer skills), and my clients love it find it easy to add text and pictures to and change their own pages - or at least they did until recently.