Jump to content


Photo

Integrating Flourish With ProcessWire

Flourish

  • Please log in to reply
22 replies to this topic

#1 netcarver

netcarver

    Sr. Member

  • Members
  • PipPipPipPip
  • 428 posts
  • 341

  • LocationUK

Posted 26 March 2012 - 12:58 PM

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 by netcarver, 21 May 2012 - 02:48 PM.

Steve ☧

#2 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 26 March 2012 - 01:21 PM

Thanks for that - it was infinitely simpler than what I'd managed to put together the last time - mich appreciated!

#3 charliez

charliez

    Jr. Member

  • Members
  • PipPip
  • 45 posts
  • 7

  • LocationCuernavaca, Mexico

Posted 26 March 2012 - 02:42 PM

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?
Carlos

#4 Michael Murphy

Michael Murphy

    Distinguished Member

  • Members
  • PipPipPip
  • 92 posts
  • 53

  • LocationBasel, Switzerland

Posted 26 March 2012 - 02:49 PM

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.

#5 Pete

Pete

    Administrator

  • Administrators
  • 1,756 posts
  • 658

  • LocationChester, England

Posted 26 March 2012 - 02:50 PM

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.

#6 Michael Murphy

Michael Murphy

    Distinguished Member

  • Members
  • PipPipPip
  • 92 posts
  • 53

  • LocationBasel, Switzerland

Posted 26 March 2012 - 02:55 PM

thanks Pete. always interested to hear about useful libraries that extend PW

#7 netcarver

netcarver

    Sr. Member

  • Members
  • PipPipPipPip
  • 428 posts
  • 341

  • LocationUK

Posted 26 March 2012 - 03:04 PM

@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.
Steve ☧

#8 charliez

charliez

    Jr. Member

  • Members
  • PipPip
  • 45 posts
  • 7

  • LocationCuernavaca, Mexico

Posted 26 March 2012 - 03:58 PM

Thanks ALL for explanations and examaples!! :)
Carlos

#9 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 405 posts
  • 118

  • LocationOttawa, Canada

Posted 20 May 2012 - 06:58 AM

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.

#10 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 405 posts
  • 118

  • LocationOttawa, Canada

Posted 21 May 2012 - 11:13 AM

Steve, is there a special reason for making the directory hidden?

DOH! Guessing this is 'cos it hides it from HTTP

#11 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 405 posts
  • 118

  • LocationOttawa, Canada

Posted 21 May 2012 - 11:42 AM

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

#12 Soma

Soma

    Hero Member

  • Moderators
  • 3,194 posts
  • 1750

  • LocationSH, Switzerland

Posted 21 May 2012 - 11:47 AM

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.

@somartist | modules created | support me, flattr my work flattr.com


#13 netcarver

netcarver

    Sr. Member

  • Members
  • PipPipPipPip
  • 428 posts
  • 341

  • LocationUK

Posted 21 May 2012 - 11:50 AM

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!
Steve ☧

#14 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 405 posts
  • 118

  • LocationOttawa, Canada

Posted 21 May 2012 - 01:08 PM

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 :)

#15 netcarver

netcarver

    Sr. Member

  • Members
  • PipPipPipPip
  • 428 posts
  • 341

  • LocationUK

Posted 21 May 2012 - 01:36 PM

Thanks for posting that Alan, I've also updated the opening post to make it a little clearer too.
Steve ☧

#16 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 405 posts
  • 118

  • LocationOttawa, Canada

Posted 21 May 2012 - 01:38 PM

Welcome Steve :D

#17 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 405 posts
  • 118

  • LocationOttawa, Canada

Posted 02 February 2013 - 11:38 AM

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:

  1. I got intrigued about ST2 here
  2. 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!) :)



#18 diogo

diogo

    Hero Member

  • Moderators
  • 2,006 posts
  • 1081

  • LocationPorto, Portugal

Posted 02 February 2013 - 12:34 PM

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.



#19 alanfluff

alanfluff

    Sr. Member

  • Members
  • PipPipPipPip
  • 405 posts
  • 118

  • LocationOttawa, Canada

Posted 02 February 2013 - 01:14 PM

Yes diogo, thanks, I certainly implied that which I hadn't meant to, thanks for clarifying that :)



#20 Soma

Soma

    Hero Member

  • Moderators
  • 3,194 posts
  • 1750

  • LocationSH, Switzerland

Posted 02 February 2013 - 04:19 PM

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:

  1. I got intrigued about ST2 here
  2. 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.c...-text-2-course/


@somartist | modules created | support me, flattr my work flattr.com





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users