netcarver Posted March 26, 2012 Share Posted March 26, 2012 (edited) I've been asked how to integrate Will Bond's Flourish library with ProcessWire so I thought I'd post the code I use. I downloaded the Flourish classes (not the whole flourish project) and put them into /site/.flourish. I then pasted the following into the top of my head.inc file. function flourish_loader( $class_name ) { // Customize this to your root Flourish directory $flourish_root = wire('config')->paths->root . 'site/.flourish/'; $file = $flourish_root . $class_name . '.php'; if (file_exists($file)) { include $file; } } spl_autoload_register( 'flourish_loader', true ); After that, you should be able to use flourish classes anywhere in your templates. NB, if you do download the whole flourish project into .flourish, then read Alan's post on how to adapt the above to your layout. Edited May 21, 2012 by netcarver 5 Link to comment Share on other sites More sharing options...
Pete Posted March 26, 2012 Share Posted March 26, 2012 Thanks for that - it was infinitely simpler than what I'd managed to put together the last time - mich appreciated! Link to comment Share on other sites More sharing options...
charliez Posted March 26, 2012 Share Posted March 26, 2012 Excuse my question if it is a stupid one! Why would you want to use Flourish with PW? after a brief browse of flourish it seems that it covers a lot of the same stuff that PW already has... isnt it? Is it used as PEAR is used? for auxiliary classes? Link to comment Share on other sites More sharing options...
Michael Murphy Posted March 26, 2012 Share Posted March 26, 2012 Thanks for sharing, Flourish looks useful and easy to use. I read in a previous post that you used the Flourish library to collect emails from an IMAP account and display them in PW. I'd be interested to hear some more potential uses of this library when combined with PW. Link to comment Share on other sites More sharing options...
Pete Posted March 26, 2012 Share Posted March 26, 2012 It's like PEAR in that it's a library of useful functions, but this one is all worked on by one guy (as far as I'm aware) so it's far more coherent than PEAR. I'm using it for things like this: http://processwire.c...ndpost__p__2407 - it just allows previewing the last 10 emails of a given inbox - in this case it's a press email account so staff can read emails and write any news or other articles based on them. I toyed with the idea of being able to grab the email text and make a page automatically from it, but as anyone who's worked with emails knows you can end up with all sorts of formatting issues. Even if you remove all the formatting it does seem like overkill anyway. I basically lost all my progress on that when my hard drive died last year, but it's actually not that hard to do things like that with Flourish and PW. There is another topic on the forums where various newsletter systems were mentioned and that got me thinking (on a basic level) of something like PHPMailer too - before I remembered Flourish can cover that need - so there are things that PW can't do where it's useful to know about other well-coded classes and libraries to help out. Oh, and before I forget - try this in your config instead of that $_SERVER['DOCUMENT_ROOT'] netcarver: $flourish_root = wire('config')->paths->root . 'site/.flourish/'; Either will work of course, but I've had weird experiences with servers and paths in the past so I just felt a bit safer knowing I was definitely using the same paths throughout my code. 1 Link to comment Share on other sites More sharing options...
Michael Murphy Posted March 26, 2012 Share Posted March 26, 2012 thanks Pete. always interested to hear about useful libraries that extend PW Link to comment Share on other sites More sharing options...
netcarver Posted March 26, 2012 Author Share Posted March 26, 2012 @Pete, Good call, thanks for the update. @Michael, I use several classes regularly from Flourish and, as I just added a contact form to my first PW, I used the fValidation class for form validation & the fSMTP and fEmail classes to send things out via my SMTP server on successful form submission. Link to comment Share on other sites More sharing options...
charliez Posted March 26, 2012 Share Posted March 26, 2012 Thanks ALL for explanations and examaples!! Link to comment Share on other sites More sharing options...
alan Posted May 20, 2012 Share Posted May 20, 2012 Doing a very lightweight events system so _thank you_ Steve + Pete for this perfect thread to help me get started. I don't know if I am adding Flourish for a weak reason (I'm not strong at PHP date manipulation (or anything else PHP ) but even if I am, it will team me some stuff I am sure. Link to comment Share on other sites More sharing options...
alan Posted May 21, 2012 Share Posted May 21, 2012 Steve, is there a special reason for making the directory hidden? DOH! Guessing this is 'cos it hides it from HTTP 1 Link to comment Share on other sites More sharing options...
alan Posted May 21, 2012 Share Posted May 21, 2012 Steve, sorry to bug you o_O I've added Flourish, used it and am getting an error. Any clues you can kick my way? https://gist.github.com/2763197 Link to comment Share on other sites More sharing options...
Soma Posted May 21, 2012 Share Posted May 21, 2012 Looks like the date class isn't loaded. Make sure you have all classes in /.flourish and not in a subfolder. So should be like /.flourish/fDate.php. 1 Link to comment Share on other sites More sharing options...
netcarver Posted May 21, 2012 Author Share Posted May 21, 2012 Alan, You got it! Yes, PW's default .htaccess file prevents web access to directories starting with a period. Also, like Soma said above, all of the flourish classes need to be in that .flourish directory, not some sub-directory of it, if you want the class loader I posted to work out of the box. Have fun! 1 Link to comment Share on other sites More sharing options...
alan Posted May 21, 2012 Share Posted May 21, 2012 Soma, Steve, thanks again you guys! Because I use SourceTree.app to download from github things likes modules etc (and so keep them up to date and see when there are updates v.easily) I was keen to keep the installed Flourish 'standard' so rather than move the classes (I had missed that I was calling classes and they were represented by those files in that folder — DOH) I just edited the path in the loader to $flourish_root = wire('config')->paths->root . 'site/.flourish/classes/'; and of course it all works! Thanks Link to comment Share on other sites More sharing options...
netcarver Posted May 21, 2012 Author Share Posted May 21, 2012 Thanks for posting that Alan, I've also updated the opening post to make it a little clearer too. 1 Link to comment Share on other sites More sharing options...
alan Posted May 21, 2012 Share Posted May 21, 2012 Welcome Steve Link to comment Share on other sites More sharing options...
alan Posted February 2, 2013 Share Posted February 2, 2013 Related (by who makes Flourish; Will Bond), I am in the process of being smitten by a new (to me) code editor, Sublime Text 2. Although people's needs and tastes vary I thought I would note this down in case anyone else finds it handy (I should likely be posting this somewhere else, sorry). In short: ST2 is so much more than I had at first thought and addresses the real pain when trying to get Coda 2, for example, to do a little more, like Zen Coding/Emmet—yes it can be coerced to do that but it feels bleeding edge, not normal. Expanding and customizing ST2 on the other hand feels natural. In danger of writing a whole video's worth of copy I'll stop and just note two links: I got intrigued about ST2 here the eloquent Jeffrey Way totally convinced me here (this is a free, full video course) Mood: excited; PW, ST2 and just-subscribed tutsplus.com training. PS: Had more info on SFTP from the clever Mr Bond but that'll have to wait for a blogpost. Better make one (in PW!) Link to comment Share on other sites More sharing options...
diogo Posted February 2, 2013 Share Posted February 2, 2013 Thanks for the links Alan. Just one correction. Sublime Text is not from Will Bond, he "only" made some packages for it. The developer of ST is a guy called Jon Skinner. 1 Link to comment Share on other sites More sharing options...
alan Posted February 2, 2013 Share Posted February 2, 2013 Yes diogo, thanks, I certainly implied that which I hadn't meant to, thanks for clarifying that Link to comment Share on other sites More sharing options...
Soma Posted February 2, 2013 Share Posted February 2, 2013 Related (by who makes Flourish; Will Bond), I am in the process of being smitten by a new (to me) code editor, Sublime Text 2. Although people's needs and tastes vary I thought I would note this down in case anyone else finds it handy (I should likely be posting this somewhere else, sorry). In short: ST2 is so much more than I had at first thought and addresses the real pain when trying to get Coda 2, for example, to do a little more, like Zen Coding/Emmet—yes it can be coerced to do that but it feels bleeding edge, not normal. Expanding and customizing ST2 on the other hand feels natural. In danger of writing a whole video's worth of copy I'll stop and just note two links: I got intrigued about ST2 here the eloquent Jeffrey Way totally convinced me here (this is a free, full video course) Mood: excited; PW, ST2 and just-subscribed tutsplus.com training. PS: Had more info on SFTP from the clever Mr Bond but that'll have to wait for a blogpost. Better make one (in PW!) See also this thread: http://processwire.com/talk/topic/1888-sublime-text-2-course/ Link to comment Share on other sites More sharing options...
alan Posted February 2, 2013 Share Posted February 2, 2013 Tks Soma. I am *sure* I tried ST2 a long time ago and simply didn't try to see how it worked (it didn't impress me with the prettiness of Coda). But this time I watched the video that's liked to and finally 'got it'. It's unbeatable and I've not even used it in a proper project yet. Link to comment Share on other sites More sharing options...
Adam Kiss Posted February 7, 2013 Share Posted February 7, 2013 Also, shameless self-plug here: for even easier way to install, use & manage your Flourish install, checkout my new micro-module: http://processwire.com/talk/topic/2756-libflourish-%E2%80%93-flourish-auto-loader-for-processwire/ 3 Link to comment Share on other sites More sharing options...
alan Posted February 7, 2013 Share Posted February 7, 2013 Very nice, thanks for sharing adamkiss! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now