AMPXF - AMP for Xenforo 2

AMPXF - AMP for Xenforo 2 [Paid] 1.4.9

No permission to buy (€50.00)
Oh okay, yeah the data-nav-id-attrs are irrelevant for the AMP pages (they are used by JS in the canonical pages..)

The amp addon does, however add an amp-state-element there to keep track of some similar things, and it has an ID that matched the "node ID" and can be utilized with a "sibling selector" to hide the link:
Code:
#homeVisible + a {
    display: none;
}

You could also achieve the same thing with the following rule, but it will hide all links to "home" in the menu..:
Code:
.M [href="/"] {
    display: none;
}

Cheers
//Jonathan
Great help, thank you! :)
 
Getting the following errors recently:

Code:
ErrorException: Template error: [E_WARNING] Attempt to read property "Data" on null
src/addons/XFMG/Entity/MediaItem.php:997
Generated by: Unknown account
Mar 4, 2022 at 5:13 PM

Stack trace
#0 src/addons/XFMG/Entity/MediaItem.php(997): XF\Template\Templater->handleTemplateError(2, '[E_WARNING] Att...', '/home/nginx/dom...', 997)
#1 src/XF/Mvc/Entity/Entity.php(160): XFMG\Entity\MediaItem->getStructuredData()
#2 src/XF/Mvc/Entity/Entity.php(118): XF\Mvc\Entity\Entity->get('structured_data')
#3 internal_data/code_cache/templates/l2/s12/public/xfmg_media_view.php(43): XF\Mvc\Entity\Entity->offsetGet('structured_data')
#4 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(MaZ\AMP\XF\Template\XF22\Templater), Array, NULL)
#5 src/addons/MaZ/AMP/XF/Template/XF22/Templater.php(52): XF\Template\Templater->renderTemplate('xfmg_media_view', Array, true, NULL)
#6 src/XF/Template/Template.php(24): MaZ\AMP\XF\Template\XF22\Templater->renderTemplate('public:xfmg_med...', Array)
#7 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#8 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XFMG:Media\\View', 'public:xfmg_med...', Array)
#9 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#11 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#12 src/XF/App.php(2351): XF\Mvc\Dispatcher->run()
#13 src/XF.php(517): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}

Request state
array(4) {
  ["url"] => string(40) "/media/img_1543746843996-jpg.1328252/"
  ["referrer"] => bool(false)
  ["_GET"] => array(1) {
    ["/media/fb_img_1543746843996-jpg_1328252/"] => string(0) ""
  }
  ["_POST"] => array(0) {
  }
}

Similar errors: Attempt to read property height/width/extension
 
Getting the following errors recently:

Code:
ErrorException: Template error: [E_WARNING] Attempt to read property "Data" on null
src/addons/XFMG/Entity/MediaItem.php:997
Generated by: Unknown account
Mar 4, 2022 at 5:13 PM

Stack trace
#0 src/addons/XFMG/Entity/MediaItem.php(997): XF\Template\Templater->handleTemplateError(2, '[E_WARNING] Att...', '/home/nginx/dom...', 997)
#1 src/XF/Mvc/Entity/Entity.php(160): XFMG\Entity\MediaItem->getStructuredData()
#2 src/XF/Mvc/Entity/Entity.php(118): XF\Mvc\Entity\Entity->get('structured_data')
#3 internal_data/code_cache/templates/l2/s12/public/xfmg_media_view.php(43): XF\Mvc\Entity\Entity->offsetGet('structured_data')
#4 src/XF/Template/Templater.php(1651): XF\Template\Templater->{closure}(Object(MaZ\AMP\XF\Template\XF22\Templater), Array, NULL)
#5 src/addons/MaZ/AMP/XF/Template/XF22/Templater.php(52): XF\Template\Templater->renderTemplate('xfmg_media_view', Array, true, NULL)
#6 src/XF/Template/Template.php(24): MaZ\AMP\XF\Template\XF22\Templater->renderTemplate('public:xfmg_med...', Array)
#7 src/XF/Mvc/Renderer/Html.php(50): XF\Template\Template->render()
#8 src/XF/Mvc/Dispatcher.php(460): XF\Mvc\Renderer\Html->renderView('XFMG:Media\\View', 'public:xfmg_med...', Array)
#9 src/XF/Mvc/Dispatcher.php(442): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(402): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#11 src/XF/Mvc/Dispatcher.php(60): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#12 src/XF/App.php(2351): XF\Mvc\Dispatcher->run()
#13 src/XF.php(517): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}

Request state
array(4) {
  ["url"] => string(40) "/media/img_1543746843996-jpg.1328252/"
  ["referrer"] => bool(false)
  ["_GET"] => array(1) {
    ["/media/fb_img_1543746843996-jpg_1328252/"] => string(0) ""
  }
  ["_POST"] => array(0) {
  }
}

Similar errors: Attempt to read property height/width/extension
Doesn't look like it would be error related to AMPXF.. Mostly because it happens on a non-AMP url 😊
 
This add-on has not resulted in any noticeable increase in traffic for me. My license just expired and I will not be renewing.

I respect your opinion, but to share an example for everyone :)

I'm not seeing some degree of significant traffic or revenue increase from this addon, but am seeing a percentage of mobile users being shown my AMP pages on their first page view.

Would their experience be negatively impacted if I took AMP away? I know of users on my site from roadsides taking a break or solving a problem. With everything else I'm doing (webp, litespeed, compression, http/3, caching, limited cdn, & etc), the only circumstance not having AMP would make a noticeble difference is poor LTE/5G coverge or an older mobile device.

Mobile usage is now 61% of my site's traffic, which is crazy, users would rather be on my site from anywhere but home :rolleyes:

I realize AMP doesn't have the focus it once did, but feel it offers benefits for first-page viewers who may not fully understand how to use their devices or are browsing from less-than-ideal conditions.

Hope this helps,
 
Can you be more specific on what news this is?
About that:

 
About that:

Those are not really news anymore :) It has been discussed somewhere in this thread :D

But to summarize:
AMP pages are still faster than the canonical pages in terms of load time and resource usage on mobile devices.
Even if AMP is no longer a ranking factor (was it ever?), it doesn't really matter as the AMP pages will be optimized for many other confirmed ranking factors.

Hope that helps!
//Jonathan
 
Those are not really news anymore :) It has been discussed somewhere in this thread :D

But to summarize:
AMP pages are still faster than the canonical pages in terms of load time and resource usage on mobile devices.
Even if AMP is no longer a ranking factor (was it ever?), it doesn't really matter as the AMP pages will be optimized for many other confirmed ranking factors.

Hope that helps!
//Jonathan
Ohh okay. Thank you for your response. So its worths i let it running? Actually i have 100 mobile and pc on pagespeed whitout amp, but much less when i test a thread without amp too.

Its true, i Can see much more speed with amp for threads
 
Hello @mazzly

XF 2.2.9
PHP 8.1.4
AMP latest

(I have now switched to PHP 8.0.17 until you can fix the problem.)

2 Warnings:
1.)
  • ErrorException: [E_DEPRECATED] substr_count(): Passing null to parameter #1 ($haystack) of type string is deprecated
  • src/addons/MaZ/AMP/Markup.php:242

  • Generiert von: Unbekanntes Konto
  • 13 Apr 2022 um 23:21


Stack-Trace​


#0 [internal function]: XF::handlePhpError(8192, '[E_DEPRECATED] ...', '/var/www/vhosts...', 242)
#1 src/addons/MaZ/AMP/Markup.php(242): substr_count(NULL, '.')
#2 src/addons/MaZ/AMP/Markup.php(223): MaZ\AMP\Markup::validate_rfc2396_url('mailto:?subject...')
#3 [internal function]: MaZ\AMP\Markup::URLHandler(Array)
#4 src/addons/MaZ/AMP/Markup.php(194): preg_replace_callback('# href="(.*?)"#...', Array, '<body>


<div c...')
#5 [internal function]: MaZ\AMP\Markup::bodyHandler(Array)
#6 src/addons/MaZ/AMP/Markup.php(47): preg_replace_callback('#<body.*?>.+?</...', Array, '<!doctype html>...')
#7 src/addons/MaZ/AMP/Listener.php(134): MaZ\AMP\Markup::cleanup('<!doctype html>...')
#8 src/XF/Extension.php(69): MaZ\AMP\Listener::app_complete(Object(XF\Pub\App), Object(XF\Http\Response))
#9 src/XF/App.php(2854): XF\Extension->fire('app_complete', Array, NULL)
#10 src/XF/App.php(2118): XF\App->fire('app_complete', Array)
#11 src/XF/Pub/App.php(455): XF\App->complete(Object(XF\Http\Response))
#12 src/XF/App.php(2355): XF\Pub\App->complete(Object(XF\Http\Response))
#13 src/XF.php(524): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}


Status der Anfrage​


array(4) {
["url"] => string(81) "/threads/wie-lange-darf-zustellung-des-vergleichsprotokols-dauern-sg.77995/?amp=1"
["referrer"] => bool(false)
["_GET"] => array(1) {
["amp"] => string(1) "1"
}
["_POST"] => array(0) {
}
}

2.)
  • ErrorException: [E_DEPRECATED] explode(): Passing null to parameter #2 ($string) of type string is deprecated
  • src/addons/MaZ/AMP/Markup.php:250

  • Generiert von: Unbekanntes Konto
  • 13 Apr 2022 um 23:21

Stack-Trace​


#0 [internal function]: XF::handlePhpError(8192, '[E_DEPRECATED] ...', '/var/www/vhosts...', 250)
#1 src/addons/MaZ/AMP/Markup.php(250): explode('/', NULL)
#2 src/addons/MaZ/AMP/Markup.php(223): MaZ\AMP\Markup::validate_rfc2396_url('https://www.elo...')
#3 [internal function]: MaZ\AMP\Markup::URLHandler(Array)
#4 src/addons/MaZ/AMP/Markup.php(194): preg_replace_callback('# href="(.*?)"#...', Array, '<body>


<div c...')
#5 [internal function]: MaZ\AMP\Markup::bodyHandler(Array)
#6 src/addons/MaZ/AMP/Markup.php(47): preg_replace_callback('#<body.*?>.+?</...', Array, '<!doctype html>...')
#7 src/addons/MaZ/AMP/Listener.php(134): MaZ\AMP\Markup::cleanup('<!doctype html>...')
#8 src/XF/Extension.php(69): MaZ\AMP\Listener::app_complete(Object(XF\Pub\App), Object(XF\Http\Response))
#9 src/XF/App.php(2854): XF\Extension->fire('app_complete', Array, NULL)
#10 src/XF/App.php(2118): XF\App->fire('app_complete', Array)
#11 src/XF/Pub/App.php(455): XF\App->complete(Object(XF\Http\Response))
#12 src/XF/App.php(2355): XF\Pub\App->complete(Object(XF\Http\Response))
#13 src/XF.php(524): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}


Status der Anfrage​


array(4) {
["url"] => string(50) "/threads/fahrtkosten-massnahmeabbruch.29007/?amp=1"
["referrer"] => bool(false)
["_GET"] => array(1) {
["amp"] => string(1) "1"
}
["_POST"] => array(0) {
}
 
How can I call the m--article class in amp_extra.less template? .m--article is just not working, neither is .message--article.

I’m trying to edit the font size in the body of the article in article thread types only.
 
Last edited:
How can I call the m--article class in amp_extra.less template? .m--article is just not working, neither is .message--article.

I’m trying to edit the font size in the body of the article in article thread types only.
It seems the article pages have the <article class="...."> which contains newlines and therefore the function that extracts the used classes didn't pick it up. I'm not sure if this is a "bug" in the template from XF core, or it is some addon we both have installed (I was able to reproduce it on local instance), either way they fix was rather straightforward :) 👍

I sent you an updated version, if all is good we'll release it for everyone tomorrow :)

Cheers
//Jonathan
 
Top Bottom