Skip to content
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
31 changes: 31 additions & 0 deletions Block/Social/AddThis.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Magefan\Blog\Block\Social;

use Magento\Store\Model\ScopeInterface;

class AddThis extends \Magento\Framework\View\Element\Template
{
public function getAddThisPubId()
{
return $this->_scopeConfig->getValue(
'mfblog/social/add_this_pubid', ScopeInterface::SCOPE_STORE
);
}

public function getAddThisLanguage()
{
return $this->_scopeConfig->getValue(
'mfblog/social/add_this_language', ScopeInterface::SCOPE_STORE
);
}

public function toHtml()
{
if (!$this->getAddThisPubId()) {
return '';
}

return parent::toHtml();
}
}
9 changes: 9 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@
<comment>E.g.: "search" will make the blog search accessible from mystore.com/{blog_route}/search/query/</comment>
</field>
</group>
<group id="social" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Social</label>
<field id="add_this_pubid" type="text" translate="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>AddThis ID</label>
</field>
<field id="add_this_language" type="text" translate="label" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>AddThis Language</label>
</field>
</group>
</section>
</system>
</config>
4 changes: 4 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
<author_route>author</author_route>
<search_route>search</search_route>
</permalink>
<social>
<add_this_pubid>ra-4def63cd3cf37569</add_this_pubid>
<add_this_language>en</add_this_language>
</social>
</mfblog>
</default>
</config>
2 changes: 2 additions & 0 deletions view/frontend/layout/blog_post_list.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<action method="setToolbarBlockName">
<argument name="name" xsi:type="string">post_list_toolbar</argument>
</action>

<block class="Magefan\Blog\Block\Social\AddThis" name="addthis.js.init" as="addthisJs" template="Magefan_Blog::addthis-js.phtml"/>
</referenceBlock>
</body>
</page>
2 changes: 1 addition & 1 deletion view/frontend/layout/blog_post_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<block class="Magefan\Blog\Block\Post\View\RelatedPosts" name="blog.post.relatedposts" as="relatedposts" template="Magefan_Blog::post/view/relatedposts.phtml" />
<block class="Magefan\Blog\Block\Post\View\RelatedProducts" name="blog.post.relatedproducts" as="relatedproducts" template="Magefan_Blog::post/view/relatedproducts.phtml" />
<block class="Magefan\Blog\Block\Post\View\Comments" name="blog.post.comments" template="post/view/comments.phtml" />
<block class="Magento\Framework\View\Element\Template" name="blog.post.js" as="js" template="Magefan_Blog::post/view/js.phtml" />
<block class="Magefan\Blog\Block\Social\AddThis" name="addthis.js.init" as="addthisJs" template="Magefan_Blog::addthis-js.phtml"/>
</block>
</block>
</referenceContainer>
Expand Down
7 changes: 7 additions & 0 deletions view/frontend/templates/addthis-js.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<script type="text/javascript">
var addthis_config = {
"ui_language": '<?php echo $this->getAddThisLanguage(); ?>',
"data_track_clickback":false
}
</script>
<script type="text/javascript" async src="//s7.addthis.com/js/250/addthis_widget.js#pubid=<?php echo $this->getAddThisPubId(); ?>"></script>
10 changes: 1 addition & 9 deletions view/frontend/templates/post/list.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,5 @@ $_postCollection = $block->getPostCollection();
</div>

<?php echo $block->getToolbarHtml() ?>

<script type="text/javascript">var addthis_config = {"data_track_clickback":false};</script>
<script type="text/javascript" async src="//s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4def63cd3cf37569"></script>
<script type="text/javascript">
var addthis_config = {
ui_language: "en",
data_track_clickback : false
}
</script>
<?php echo $this->getChildHtml('addthisJs'); ?>
<?php endif; ?>
22 changes: 0 additions & 22 deletions view/frontend/templates/post/view/js.phtml

This file was deleted.