As I mentioned in a previous post, 0.7.0.0 would possibly break some users custom templates. Here’s methods that changed…
- getAddresses()
- getPhoneNumbers()
- getEmailAddresses()
- getIm()
- getSocialMedia()
- getWebsites()
Each of these now return a standard object. And the related helper classes have been removed. See the PHP documentation in the class.entry.php for each one of these methods to see the objects content for each data type.
Here’s a sample of a way you might have used the getSocialMedia() method previoulsy in a template:
if ($entry->getSocialMedia()) { $SocialMediaObject = new cnSocialMedia(); foreach ($entry->getSocialMedia() as $SocialMediaRow) { if ($SocialMediaObject->getId($SocialMediaRow) != null) { switch ($SocialMediaRow['type']) { case 'twitter': // CODE HERE; break; case 'facebook': // CODE HERE; break; } } } } |
Here’s the same code corrected for versions 0.7.0.0 and newer:
if ($entry->getSocialMedia()) { foreach ($entry->getSocialMedia() as $network) { if ($network->id != null) { switch ($network->type) { case 'twitter': // CODE HERE; break; case 'facebook': // CODE HERE; break; } } } } |