20
Tridion and PHP Don’t Mix …or Do They?

Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Embed Size (px)

Citation preview

Page 1: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

 Tridion and PHP Don’t Mix…or Do They?

Page 2: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Abstract

• Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s. .NET or Java.

• I will show some sample code and discuss the kind of TCDL handlers that need to be developed, and the difficulty/ease of doing so.

Page 3: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

About Us

• A lot of credit goes to Jon Primmer for getting much of the technical detail

• Feel free to reach out:– Jon Primmer: @jonnybeemud ; [email protected]– Nick Roussakov: @nroussakov ; [email protected]

Page 4: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Why PHP, all of a sudden?

• We recently had a few customers request Tridion integrations with their PHP front-end applications.

• PHP is free and has a plethora of open-source products starting to seep into the enterprise. For example:– Magento e-comm platform– Drupal– Wordpress– SugarCRM– Silverstripe– CodeIgniter MVC framework– Has frameworks to do just about everything (even LINQ - http://phplinq.codeplex.com/)

• PHP version 5.3 has very robust OOP capability• Coding PHP doesn’t suck any more.• Eclipse with IntelliSense works great• Xdebug

Page 5: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

So how do you integrate a PHP solution with SDL Tridion?

• Our first thought: “Static Publishing”– Render any kind of text file and place it on the host server.– Get creative with “include” files.

• For example, a Page in Tridion with a set of Component Presentations published as an “include” file gives another level for nesting Component Presentations.

• What if we need to have the ability to target content based on, say, taxonomy (keywords or custom metadata)?– Have taxonomy-driven navigation– Quicker (more efficient) way to update and publish content– Share published content from a single source

• … and so we explore Tridion’s Dynamic Content Delivery

Page 6: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Dynamic Content Delivery Options for non-Java/.NET Web Apps

• Traditionally, Tridion’s Dynamic Delivery was available for Java and .NET -based applications

• This meant having to create a custom wrapper around the Java or .NET APIs

• With SDL Tridion 2011 a new Content Delivery Web service is available (a.k.a. Tridion Odata)

• (There is also REL)

Page 7: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

"You mean I finally have frickin' sharks with frickin' laser beams

attached to their frickin' heads?"

Page 8: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Odata Sample Output

Page 9: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Consuming the Dynamic Content

• In our page template we frequently use this code:

• When the output format and delivery target language are set to REL, we get the following on our php page:

Page 10: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Consuming the Dynamic Content (cont.)

• All we need now is a Tridion Building Block that will catch this during publishing and replace it with PHP code to call oData

Page 11: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Optimizing oData Calls

• Odata querying just the right amount of data:– Does filtering via LINQ require sending too much across the wire (e.g.

/ComponentPresentations returns all the CPs from the Broker and filtering on application side)?• No. See http://msdn.microsoft.com/en-us/library/ee622463.aspx

• What about with Java or PHP?– Need to fine-tune our Odata queries using $filter, $expand– E.g. Get Component Presentations where CustomMeta key = “foo”, such that the fewest

number of HTTP Requests go out.

• The answer: caching– Tridion’s Cache Channel Service on top of oData– A caching appliance– Application-level caching, e.g. CodeIgniter Cache (https://

github.com/philsturgeon/codeigniter-cache)

Page 12: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Make the Odata Query as Drilled Down as Possible

QueryOne: ComponentPresentations based on component custom meta field------------------http://localhost:82/odata.svc/CustomMetas?$filter=StringValueeq%20%27Golf%27&$expand=Component/ComponentPresentations

QueryTwo: All custom meta of componet presentations based on a specific template------------------localhost:82/odata.svc/ComponentPresentations?$filter=TemplateId eq 666 and publicationId eq 8&$expand=Component/CustomMetas

Page 13: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Sample Output

Page 14: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

What About Add-on Modules and Products?

• Tridion Experience Manager (the new SiteEdit)• Profiling and Personalization• Fredhopper

Page 15: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Tridion Experience Manager

• The staging site runs in an iFrame, so technically it can be on any language platform (PHP, python, whatever)

• The caveat is Session Preview, which requires the staging site to be able to run Java (Content Delivery API and Ambient Data Framework jars).– Possible to run PHP on a Java App server, e.g.:– Tomcat AJP Connector: http://

tomcat.apache.org/tomcat-3.2-doc/tomcat-apache-howto.html– or PHP to Java Bridge: http://

php-java-bridge.sourceforge.net/doc/tomcat6.php – This is still in experimental stages

Page 16: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Profiling and Personalization

• Tridion offers the ability to set up Target Groups based on keyword tracking and other criteria

• Unfortunately this requires storing cookies on the client machine. The Contenet Delivery Web Service can’t do that.

• Good news: we can build our own…

Page 17: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Profiling and Personalization

• A custom TCDL handler can be created to translate the target group syntax into PHP code, which talks to the Broker

Page 18: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Fredhopper

• SmartTarget is the product that integrates Fredhopper with Tridion.

• The Ambient Data Framework is used in between• For PHP integration, a custom solution can be

built on top of Fredhopper’s web service APIs.• Probably can’t make it as good as SDL’s ADF, but

possible to make it good-enough for the immediate functionality required.

Page 19: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

Thanks

• Questions?

Page 20: Tridion and PHP Don’t Mix …or Do They?. Abstract Using PHP and Dynamic Publishing, the considerations and the limitations of using PHP via OData v.s..NET

About Content Bloom

• Offices in Toronto, Brussels and UK• Certified SDL Tridion consultancy and partner• Strong knowledge and deep roots within the

SDL Tridion product suite