From 58c2258ffe83d3f9f18a24dd738d669458176ee8 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sun, 4 Jan 2015 15:31:06 +0700 Subject: [PATCH 1/3] Fixes #51 : Share facebook button count --- module/Application/Module.php | 11 +++++++++ module/Application/view/layout/2columns.phtml | 3 +-- module/Application/view/layout/header.phtml | 23 ++++++++++--------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/module/Application/Module.php b/module/Application/Module.php index a528186..d951276 100644 --- a/module/Application/Module.php +++ b/module/Application/Module.php @@ -55,14 +55,25 @@ public function onDispatch(MvcEvent $e) $controllerClass = get_class($controller); $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\')); + $fbMeta['title'] = 'Real Life Learn ZF2'; + $fbMeta['description'] = ''; + // set title prepend of module desc... $moduleDetail = $this->services->get('Doctrine\ORM\EntityManager')->getRepository('Application\Entity\ModuleList')->findOneBy([ 'moduleName' => $moduleNamespace, ]); + if ($moduleDetail) { $this->services->get('ViewHelperManager')->get('headTitle')->prepend($moduleDetail->getModuleDesc()); + $title = $moduleDetail->getModuleDesc(); + $description = $moduleDetail->getModuleDesc(); + + $fbMeta['title'] = $title.'-'.$fbMeta['title']; + $fbMeta['description'] = $description.'-'.$fbMeta['description']; } + $e->getViewModel()->setVariable('fbMeta', $fbMeta); + $e->getViewModel()->setVariable('modulenamespace', $moduleNamespace); $controller->layout('layout/2columns'); } diff --git a/module/Application/view/layout/2columns.phtml b/module/Application/view/layout/2columns.phtml index decdc37..2c2b896 100644 --- a/module/Application/view/layout/2columns.phtml +++ b/module/Application/view/layout/2columns.phtml @@ -1,6 +1,5 @@ render('layout/header'); ?> -
@@ -26,7 +25,7 @@
-
+


diff --git a/module/Application/view/layout/header.phtml b/module/Application/view/layout/header.phtml index 9b3cd44..7adef70 100644 --- a/module/Application/view/layout/header.phtml +++ b/module/Application/view/layout/header.phtml @@ -8,6 +8,9 @@ headMeta() ->appendName('viewport', 'width=device-width, initial-scale=1.0') ->appendHttpEquiv('X-UA-Compatible', 'IE=edge') + ->setProperty('og:title', $this->layout()->fbMeta['title']) + ->setProperty('og:description', $this->layout()->fbMeta['description']) + ->setProperty('og:image', $this->serverUrl() . '/img/zf2-logo.png'); ?> @@ -27,20 +30,18 @@ ->prependFile($this->basePath() . '/js/jquery.min.js') ->prependFile($this->basePath() . '/js/respond.min.js', 'text/javascript', array('conditional' => 'lt IE 9',)) ->prependFile($this->basePath() . '/js/html5shiv.js', 'text/javascript', array('conditional' => 'lt IE 9',)) - ; ?> - + ; + ?>
- +