File tree 3 files changed +37
-28
lines changed
3 files changed +37
-28
lines changed Original file line number Diff line number Diff line change @@ -55,18 +55,21 @@ protected function _prepareLayout()
55
55
56
56
if ($ this ->config ->getDisplayCanonicalTag (\Magefan \Blog \Model \Config::CANONICAL_PAGE_TYPE_AUTHOR )) {
57
57
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
+ );
63
72
}
64
-
65
- $ this ->pageConfig ->addRemotePageAsset (
66
- $ canonicalUrl ,
67
- 'canonical ' ,
68
- ['attributes ' => ['rel ' => 'canonical ' ]]
69
- );
70
73
}
71
74
/*
72
75
$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()
43
43
$ this ->pageConfig ->setKeywords ($ post ->getMetaKeywords ());
44
44
$ this ->pageConfig ->setDescription ($ post ->getMetaDescription ());
45
45
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
+ }
52
55
}
53
56
54
57
$ pageMainTitle = $ this ->getLayout ()->getBlock ('page.main.title ' );
Original file line number Diff line number Diff line change @@ -73,18 +73,21 @@ protected function _prepareLayout()
73
73
74
74
if ($ this ->config ->getDisplayCanonicalTag (\Magefan \Blog \Model \Config::CANONICAL_PAGE_TYPE_TAG )) {
75
75
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
+ );
81
90
}
82
-
83
- $ this ->pageConfig ->addRemotePageAsset (
84
- $ canonicalUrl ,
85
- 'canonical ' ,
86
- ['attributes ' => ['rel ' => 'canonical ' ]]
87
- );
88
91
}
89
92
90
93
$ pageMainTitle = $ this ->getLayout ()->getBlock ('page.main.title ' );
You can’t perform that action at this time.
0 commit comments