Skip to content
This repository has been archived by the owner on Feb 27, 2024. It is now read-only.

Fixes #51 : Share facebook button count #96

Merged
merged 2 commits into from
Jan 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions module/Application/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,25 @@ public function onDispatch(MvcEvent $e)
$controllerClass = get_class($controller);
$moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));

$fbMeta['title'] = 'Real Live 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');
}
Expand Down
3 changes: 1 addition & 2 deletions module/Application/view/layout/2columns.phtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php echo $this->render('layout/header'); ?>


<div class="container container-main">

<!-- sidebar -->
Expand All @@ -26,7 +25,7 @@
<iframe src="http://ghbtns.com/github-btn.html?user=sitrunlab&repo=LearnZF2&type=fork&count=true"
allowtransparency="true" frameborder="0" scrolling="0" width="95" height="20"></iframe>
<div class="fb-wrap">
<div class="fb-share-button" data-layout="button_count" data-href="https://developers.facebook.com/docs/plugins/"></div>
<div class="fb-share-button" href="<?php echo $this->serverUrl() . $this->url(); ?>" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button_count"></div>
</div>
<br />
<br />
Expand Down
23 changes: 12 additions & 11 deletions module/Application/view/layout/header.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<?php echo $this->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');
?>

<!-- Le styles -->
Expand All @@ -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',))
; ?>

;
?>
</head>
<body>
<div id="fb-root"></div>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=471963102931624&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/id_ID/sdk.js#xfbml=1&appId=581080422025637&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
Expand Down