File tree Expand file tree Collapse file tree 3 files changed +37
-28
lines changed Expand file tree Collapse file tree 3 files changed +37
-28
lines changed Original file line number Diff line number Diff line change @@ -55,18 +55,21 @@ protected function _prepareLayout()
5555
5656 if ($ this ->config ->getDisplayCanonicalTag (\Magefan \Blog \Model \Config::CANONICAL_PAGE_TYPE_AUTHOR )) {
5757
58- $ canonicalUrl = $ author ->getAuthorUrl ();
59- $ page = (int )$ this ->_request ->getParam (Toolbar::PAGE_PARM_NAME );
60- if ($ page > 1 ) {
61- $ canonicalUrl .= ((false === strpos ($ canonicalUrl , '? ' )) ? '? ' : '& ' )
62- . Toolbar::PAGE_PARM_NAME . '= ' . $ page ;
58+ $ layoutUpdate = $ author ->getData ('layout_update_xml ' ) ?: '' ;
59+ if (false === strpos ($ layoutUpdate , 'rel="canonical" ' )) {
60+ $ canonicalUrl = $ author ->getAuthorUrl ();
61+ $ page = (int )$ this ->_request ->getParam (Toolbar::PAGE_PARM_NAME );
62+ if ($ page > 1 ) {
63+ $ canonicalUrl .= ((false === strpos ($ canonicalUrl , '? ' )) ? '? ' : '& ' )
64+ . Toolbar::PAGE_PARM_NAME . '= ' . $ page ;
65+ }
66+
67+ $ this ->pageConfig ->addRemotePageAsset (
68+ $ canonicalUrl ,
69+ 'canonical ' ,
70+ ['attributes ' => ['rel ' => 'canonical ' ]]
71+ );
6372 }
64-
65- $ this ->pageConfig ->addRemotePageAsset (
66- $ canonicalUrl ,
67- 'canonical ' ,
68- ['attributes ' => ['rel ' => 'canonical ' ]]
69- );
7073 }
7174 /*
7275 $page = $this->_request->getParam(\Magefan\Blog\Block\Post\PostList\Toolbar::PAGE_PARM_NAME);
Original file line number Diff line number Diff line change @@ -43,12 +43,15 @@ protected function _prepareLayout()
4343 $ this ->pageConfig ->setKeywords ($ post ->getMetaKeywords ());
4444 $ this ->pageConfig ->setDescription ($ post ->getMetaDescription ());
4545
46- if ($ this ->config ->getDisplayCanonicalTag (\Magefan \Blog \Model \Config::CANONICAL_PAGE_TYPE_POST )) {
47- $ this ->pageConfig ->addRemotePageAsset (
48- $ post ->getCanonicalUrl (),
49- 'canonical ' ,
50- ['attributes ' => ['rel ' => 'canonical ' ]]
51- );
46+ $ layoutUpdate = $ post ->getData ('layout_update_xml ' ) ?: '' ;
47+ if (false === strpos ($ layoutUpdate , 'rel="canonical" ' )) {
48+ if ($ this ->config ->getDisplayCanonicalTag (\Magefan \Blog \Model \Config::CANONICAL_PAGE_TYPE_POST )) {
49+ $ this ->pageConfig ->addRemotePageAsset (
50+ $ post ->getCanonicalUrl (),
51+ 'canonical ' ,
52+ ['attributes ' => ['rel ' => 'canonical ' ]]
53+ );
54+ }
5255 }
5356
5457 $ pageMainTitle = $ this ->getLayout ()->getBlock ('page.main.title ' );
Original file line number Diff line number Diff line change @@ -73,18 +73,21 @@ protected function _prepareLayout()
7373
7474 if ($ this ->config ->getDisplayCanonicalTag (\Magefan \Blog \Model \Config::CANONICAL_PAGE_TYPE_TAG )) {
7575
76- $ canonicalUrl = $ tag ->getTagUrl ();
77- $ page = (int )$ this ->_request ->getParam (Toolbar::PAGE_PARM_NAME );
78- if ($ page > 1 ) {
79- $ canonicalUrl .= ((false === strpos ($ canonicalUrl , '? ' )) ? '? ' : '& ' )
80- . Toolbar::PAGE_PARM_NAME . '= ' . $ page ;
76+ $ layoutUpdate = $ tag ->getData ('layout_update_xml ' ) ?: '' ;
77+ if (false === strpos ($ layoutUpdate , 'rel="canonical" ' )) {
78+ $ canonicalUrl = $ tag ->getTagUrl ();
79+ $ page = (int )$ this ->_request ->getParam (Toolbar::PAGE_PARM_NAME );
80+ if ($ page > 1 ) {
81+ $ canonicalUrl .= ((false === strpos ($ canonicalUrl , '? ' )) ? '? ' : '& ' )
82+ . Toolbar::PAGE_PARM_NAME . '= ' . $ page ;
83+ }
84+
85+ $ this ->pageConfig ->addRemotePageAsset (
86+ $ canonicalUrl ,
87+ 'canonical ' ,
88+ ['attributes ' => ['rel ' => 'canonical ' ]]
89+ );
8190 }
82-
83- $ this ->pageConfig ->addRemotePageAsset (
84- $ canonicalUrl ,
85- 'canonical ' ,
86- ['attributes ' => ['rel ' => 'canonical ' ]]
87- );
8891 }
8992
9093 $ pageMainTitle = $ this ->getLayout ()->getBlock ('page.main.title ' );
You can’t perform that action at this time.
0 commit comments