Thursday, June 9, 2011

Programmatically Adding Image Content in Generic Setup

Have you been sitting around for the last hour thinking "man, it would sure be great if I could add Images to my site on install but I just can't find a code example"? I know I was. Consider it documented!

There will be a slideshow in the Plone Conference 2011 website (it's coming soon I swear!) that we wanted to work on install since it was 1. on the front page and 2. a PITA to set up every time. The code below gives "a" way to do this, although it could be taken to a much more abstracted level (what couldn't?!?).

This assumes that there is a folder called images in your generic setup profile folder, which is likely to be in ... > profiles > default > images. The nice thing is that it doesn't rely on the magical, mystical .content jiggery. I won't rehash the code comments, but if you are using the slideshow product then maybe this cantation is for you!

2 comments:

  1. sweet!! that is amazeballs. no more "do shit" though? :D

    how does updating the slideshow work after this point? do you just come in and edit the script, and then reimport the thingy, or can it be done through the web after it's been installed?

    ReplyDelete
  2. yeah - sorry - we need the front page to be "the government is paying my way" acceptable :(

    Edit TTW after initial setup so you can update with new pictures whenever you WANT! I just wanted to put something in there - that's def not a final cut let's say :)

    ReplyDelete