PDA

Orijinalini görmek için tıklayınız : Integration with vBulletin - Accelerated Mobile Pages for vBulletin



vBulletin.Org
02.Kasım.2016, 03:49
What is AMP?
https://www.ampproject.org/

Info
When Google announced AMP, I realized I'd eventually need AMP support for my vBulletin forum. After reading the AMP implementation docs, I decided to modify printthread.php file since It only displays the basic elements and contents of a thread. So, you got the idea...

Implementation


You will upload 1 file to forum root: amp.php
You will edit /includes/class_bbcode.php and edit/replace a few lines.
You will add two new templates, and edit a few.
You will probably want to customize the <style amp-custom> CSS in ampthread template.

Demo


Visit any thread from https://www.msxlabs.org (https://www.msxlabs.org/) homepage.
Scroll down to footer; you will see the AMP link at the left bottom corner, click on it. It will open the AMP version of the thread.
The link is there for quick access to AMP version of a thread, It is not mandatory, nor It is used by AMP recognation.

Installation


Download and extract the ZIP file.
Upload the amp.php file to your forum root folder (same folder with showthread.php)
Add a new template called "ampthread" and copy the template content from ampthread_template.txt file.
Add a new template called "ampthreadbit" and copy the template content from ampthreadbit_template.txt file.
Edit your bbcode_quote template and replace It's content with bbcode_quote.txt file's.
Edit includes/class_bbcode.php, find:



if ($do_imgcode AND ($this->registry->userinfo['userid'] == 0 OR $this->registry->userinfo['showimages']))

replace with



if ($do_imgcode AND ($this->registry->userinfo['userid'] == 0 OR $this->registry->userinfo['showimages']) OR THIS_SCRIPT == 'amp') //amp hack


find:



return '<img src="' . $link . '" border="0" alt="" />';


replace with:



if (THIS_SCRIPT == 'amp') { return '<amp-img layout="responsive" src="' . $link . '" width="300" height="250" alt=""></amp-img>';} else { return '<img src="' . $link . '" border="0" alt="" />'; } //amp hack


Save and upload class_bbcode.php (overwrite).

Edit SHOWTHREAD template and add



<link rel="amphtml" href="http://www.vbulletin.com/amp.php?t=$threadid<if condition="$pagenumber>1">&amp;page=$pagenumber</if>" />



before </head>. Don't forget to change "yourforum.com" URL with yours.
Edit ampthread template and change "vbulletin.com" with your forum URL:




<link rel="canonical" href="http://www.vbulletin.com/showthread.php?t=$threadinfo[threadid]<if condition="$pagenumber>1">&page=$pagenumber</if>" />



Notes
I installed a fresh vBulletin 3.8 to my localhost and tested this mod. It should work just fine unless your vBulletin is highly modified. If you get validation errors, I believe you can fix them by looking at the examples (comments).


Does it work?



Open a thread from your forum.
Replace the "showthread.php" with "amp.php" in the address bar, hit enter.
Add "#development=1" at the end of the URL and refresh the page.
Open Chrome DevTools, check the console log, it should say "AMP validation successful."



https://resim.webmaster.bbs.tr/image.uploads/05-10-2017/original-115af85ade2cb30aa8993f003c742e41.png https://resim.webmaster.bbs.tr/image.uploads/05-10-2017/original-32e46594c50afbb81a21a54f6b1e2063.png https://resim.webmaster.bbs.tr/image.uploads/05-10-2017/original-210e0de0a47293c370e61559ee39fcc1.png https://resim.webmaster.bbs.tr/image.uploads/05-10-2017/original-ffea21cf837ffd49cfb150d9a326ed69.png

Original Source: Integration with vBulletin - Accelerated Mobile Pages for vBulletin (https://www.vbulletin.org/forum/showthread.php?t=323668&goto=newpost)