Go Back   vb.org Archive > vBulletin Modifications > vBulletin 3.8 Modifications > vBulletin 3.8 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Accelerated Mobile Pages for vBulletin Details »»
Accelerated Mobile Pages for vBulletin
Version: 1.00, by NeutralizeR NeutralizeR is offline
Developer Last Online: Oct 2021 Show Printable Version Email this Page

Category: Integration with vBulletin - Version: 3.8.x Rating:
Released: 10-19-2016 Last Update: 10-19-2016 Installs: 17
Template Edits
Re-useable Code Code Changes Additional Files Translations  
No support by the author.

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
  1. You will upload 1 file to forum root: amp.php
  2. You will edit /includes/class_bbcode.php and edit/replace a few lines.
  3. You will add two new templates, and edit a few.
  4. You will probably want to customize the <style amp-custom> CSS in ampthread template.
Demo
  1. Visit any thread from https://www.msxlabs.org homepage.
  2. 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.
  3. 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
  1. Download and extract the ZIP file.
  2. Upload the amp.php file to your forum root folder (same folder with showthread.php)
  3. Add a new template called "ampthread" and copy the template content from ampthread_template.txt file.
  4. Add a new template called "ampthreadbit" and copy the template content from ampthreadbit_template.txt file.
  5. Edit your bbcode_quote template and replace It's content with bbcode_quote.txt file's.
  6. Edit includes/class_bbcode.php, find:
    PHP Code:
    if ($do_imgcode AND ($this->registry->userinfo['userid'] == OR $this->registry->userinfo['showimages'])) 
    replace with:
    PHP Code:
    if ($do_imgcode AND ($this->registry->userinfo['userid'] == OR $this->registry->userinfo['showimages']) OR THIS_SCRIPT == 'amp'//amp hack 
    find:
    PHP Code:
    return '<img src="' .  $link '" border="0" alt="" />'
    replace with:
    Code:
    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
  7. Save and upload class_bbcode.php (overwrite).
  8. Edit SHOWTHREAD template and add
    Code:
    <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.
  9. Edit ampthread template and change "vbulletin.com" with your forum URL:
    Code:
    <link rel="canonical" href="http://www.vbulletin.com/showthread.php?t=$threadinfo[threadid]<if condition="$pagenumber>1">&page=$pagenumber</if>" />
  10. You will find some comments in amp.php and ampthread template; modify them according to your needs (optional).
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?

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

Snap3.png

Snap4.png

Snap5.png

Credits
Accelerated Mobile Pages for vBulletin 3.8 is created by NeutralizeR from https://www.msxlabs.org

Download Now

File Type: zip AMP for vBulletin by MsXLabs.org v1.0.zip (8.2 KB, 264 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
12 благодарности(ей) от:
A.Chakery, Abu1, blind-eddie, bond010007, Brandon Sheley, Kane@airrifle, LeventX, m7sen, Masterix, Nas.er, PinkMilk, z3r0

Comments
  #22  
Old 11-01-2016, 03:54 PM
beansbaxter's Avatar
beansbaxter beansbaxter is offline
 
Join Date: May 2005
Location: Seattle
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the feedback. I've been working in the Developer Console Log and have worked through all the errors, except for one...

I see where vBSEO is adding the <base href...> tag, however when I remove it, then the forum's CSS and Style doesn't load... not sure if there is a workaround...

This the last issue I need to resolve to validate AMP.
Reply With Quote
  #23  
Old 11-01-2016, 04:23 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by beansbaxter View Post
Thanks for the feedback. I've been working in the Developer Console Log and have worked through all the errors, except for one...

I see where vBSEO is adding the <base href...> tag, however when I remove it, then the forum's CSS and Style doesn't load... not sure if there is a workaround...

This the last issue I need to resolve to validate AMP.
Open vbseo\includes\functions_vbseo.php, find
Code:
$durl = 'http://'.$_SERVER['HTTP_HOST'];
right below this line there is a line starting with $newtext.

Replace:
Code:
$newtext = preg_replace('#<head>#i', "$0\n".'<base href="'.$durl.(defined('VBSEO_BASE_URL')?VBSEO_BASE_URL:'').'/" /><!--[if IE]></base><![endif]-->', $newtext, 1);
width:
Code:
if(THIS_SCRIPT != 'amp')
{$newtext = preg_replace('#<head>#i', "$0\n".'<base href="'.$durl.(defined('VBSEO_BASE_URL')?VBSEO_BASE_URL:'').'/" /><!--[if IE]></base><![endif]-->', $newtext, 1);}
Reply With Quote
  #24  
Old 11-01-2016, 04:54 PM
beansbaxter's Avatar
beansbaxter beansbaxter is offline
 
Join Date: May 2005
Location: Seattle
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by NeutralizeR View Post
Open vbseo\includes\functions_vbseo.php, find
Code:
$durl = 'http://'.$_SERVER['HTTP_HOST'];
right below this line there is a line starting with $newtext.

Replace:
Code:
$newtext = preg_replace('#<head>#i', "$0\n".'<base href="'.$durl.(defined('VBSEO_BASE_URL')?VBSEO_BASE_URL:'').'/" /><!--[if IE]></base><![endif]-->', $newtext, 1);
width:
Code:
if(THIS_SCRIPT != 'amp')
{$newtext = preg_replace('#<head>#i', "$0\n".'<base href="'.$durl.(defined('VBSEO_BASE_URL')?VBSEO_BASE_URL:'').'/" /><!--[if IE]></base><![endif]-->', $newtext, 1);}
Thank you so much! I tried several things and couldn't get it to work. And this worked great!

AMP is now being validated.

Thanks again. I appreciate your help.
Reply With Quote
  #25  
Old 11-01-2016, 04:56 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are welcome
Reply With Quote
  #26  
Old 11-01-2016, 07:17 PM
nw-fotografie nw-fotografie is offline
 
Join Date: Mar 2016
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great stuff!

How can we put a link in the thread tools section?

Thanks for support!

Greetings

Klaus
Reply With Quote
Благодарность от:
NeutralizeR
  #27  
Old 11-01-2016, 07:32 PM
nw-fotografie nw-fotografie is offline
 
Join Date: Mar 2016
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ok, validation makes some problems:

The attribute 'nowrap' may not appear in tag 'td'.
The attribute 'style' may not appear in tag 'div'.
The attribute 'style' may not appear in tag 'td'.
The tag 'img' may only appear as a descendant of tag 'noscript'. Did you mean 'amp-img'? 585 https://www.ampproject.org/docs/reference/amp-img.html
The attribute 'style' may not appear in tag 'div'.
The attribute 'nowrap' may not appear in tag 'td'.
The tag 'script' is disallowed except in specific forms.

Any idea how to fix this?
Reply With Quote
  #28  
Old 11-04-2016, 09:43 AM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by nw-fotografie View Post
Ok, validation makes some problems:

The attribute 'nowrap' may not appear in tag 'td'.
The attribute 'style' may not appear in tag 'div'.
The attribute 'style' may not appear in tag 'td'.
The tag 'img' may only appear as a descendant of tag 'noscript'. Did you mean 'amp-img'? 585 https://www.ampproject.org/docs/reference/amp-img.html
The attribute 'style' may not appear in tag 'div'.
The attribute 'nowrap' may not appear in tag 'td'.
The tag 'script' is disallowed except in specific forms.

Any idea how to fix this?
Helped via PM.

Note: I can't answer all questions via PM but I'll try to help you fix the validation issues. I believe we covered most of them. Some plugins globally add codes/lines to many vB pages, including AMP. You should exclude them for AMP threads.
Reply With Quote
  #29  
Old 11-04-2016, 01:52 PM
unp unp is offline
 
Join Date: Oct 2008
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have "Missing structured data element" in google webmasters.

I checked your pages and found this:

Code:
xxxxx
  "@id":"https://www.msxlabs.org/forum/amp/505911.html",
  "mainEntityOfPage":"https://www.msxlabs.org/forum/amp/505911.html",
  "datePublished":"2016-10-29T03:33:19+03:00",
  "dateModified":"2016-10-29T19:41:46+03:00",
xxxxx
I need some help with this datePublished and DateModified.

with $threadinfo[dateline & lastpost] I get unix date format.

Regards,
Reply With Quote
  #30  
Old 11-04-2016, 02:21 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

http://searchengineland.com/amp-page...console-255016

You can check this example regarding dates in unix format:
Code:
$datepublished = date('c', $post['dateline']);
Reply With Quote
  #31  
Old 11-04-2016, 05:54 PM
Masterix Masterix is offline
 
Join Date: Jan 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by NeutralizeR View Post
You don't actually need to rewrite AMP pages. AMP pages will be served by Google once they are crawled.

You can try these Custom Rewrite Rules for vBSEO:
Code:
'^amp\.php\?t=(\d+)' => 'amp/$1.html'
or
Code:
'^amp\.php\?t=(\d+)&page=(\d+)$' => 'amp/$1-$2.html'
Thanks, Google is crawling now
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:57 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04594 seconds
  • Memory Usage 2,374KB
  • Queries Executed 26 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (13)bbcode_code
  • (3)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (13)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete