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
  #12  
Old 10-27-2016, 02:54 PM
unp unp is offline
 
Join Date: Oct 2008
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am using a plugin to proxy cache remote images for https.

This is my class_bbcode-

PHP Code:
    function handle_bbcode_img_match($link)
    {
        
$link $this->strip_smilies(str_replace('\\"''"'$link));

        
// remove double spaces -- fixes issues with wordwrap
        
$link str_replace(array('  ''"'), ''$link);

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

    (
$hook vBulletinHook::fetch_hook('bbcode_img_match')) ? eval($hook) : false;

    return 
$retval;
    } 
And this is the plugin I am using-

PHP Code:
$url parse_url($link);

if (
$url['scheme'] == 'https') {
$retval = ($fullsize '<div class="size_fullsize">' '')  . '<img src="' $link .'" border="0" alt="" />' . ($fullsize '</div>' '');
} elseif (
$url['host'] == 'www.site.com') {
$retval = ($fullsize '<div class="size_fullsize">' '')  . '<img src="' $link .'" border="0" alt="" />' . ($fullsize '</div>' '');
} else {
$retval = ($fullsize '<div class="size_fullsize">' '')  . '<img src="cache.php?img=' rawurlencode($link) .'" border="0" alt="" />' . ($fullsize '</div>' '');

Kindly help.
Reply With Quote
  #13  
Old 10-27-2016, 06:14 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Modify your class_bbcode.php as told in first post.

Replace your plugin with:
Code:
$url = parse_url($link);

//amphack
if (THIS_SCRIPT == 'amp') {

if ($url['scheme'] == 'https') {
$retval = ($fullsize ? '<div class="size_fullsize">' : '')  . '<amp-img layout="responsive" src="' . $link .'" alt="" />' . ($fullsize ? '</div>' : '');
} elseif ($url['host'] == 'www.site.com') {
$retval = ($fullsize ? '<div class="size_fullsize">' : '')  . '<amp-img layout="responsive" src="' . $link .'" alt="" />' . ($fullsize ? '</div>' : '');
} else {
$retval = ($fullsize ? '<div class="size_fullsize">' : '')  . '<amp-img layout="responsive" src="cache.php?img=' . rawurlencode($link) .'" alt="" />' . ($fullsize ? '</div>' : '');
}

}
else
{
if ($url['scheme'] == 'https') {
$retval = ($fullsize ? '<div class="size_fullsize">' : '')  . '<img src="' . $link .'" border="0" alt="" />' . ($fullsize ? '</div>' : '');
} elseif ($url['host'] == 'www.site.com') {
$retval = ($fullsize ? '<div class="size_fullsize">' : '')  . '<img src="' . $link .'" border="0" alt="" />' . ($fullsize ? '</div>' : '');
} else {
$retval = ($fullsize ? '<div class="size_fullsize">' : '')  . '<img src="cache.php?img=' . rawurlencode($link) .'" border="0" alt="" />' . ($fullsize ? '</div>' : '');
}

}
//amp hack
Reply With Quote
  #14  
Old 10-30-2016, 09:23 AM
Masterix Masterix is offline
 
Join Date: Jan 2008
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed but VBSEO rewrite showthread.php

Any Help?

OK, my bad
https://www.elo-forum.org/amp.php?t=92082&page=5
anyway need to add or change a rewriterule?

EDIT
Ok, with vbseo you dont need any rewriterule!
Goto your VBSEO-Admincp. Select: "General Settings" -> "vBSEO Basic Settings".
Scoll down to "Exclusion of pages?". Add there amp.php and save your settings.

Btw. Thanks in advance!
Reply With Quote
  #15  
Old 10-30-2016, 05:08 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'
Reply With Quote
  #16  
Old 11-01-2016, 02:15 PM
beansbaxter's Avatar
beansbaxter beansbaxter is offline
 
Join Date: May 2005
Location: Seattle
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed on 3.8.8 PL2 and seems to work... however, the website is in English and Chrome thinks the AMP page is in Turkish and wants to translate? How to resolve?

Example Thread - http://pnwmoto.com/amp/2425.html

And thanks for building this mod!
Reply With Quote
Благодарность от:
NeutralizeR
  #17  
Old 11-01-2016, 02:39 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by beansbaxter View Post
Installed on 3.8.8 PL2 and seems to work... however, the website is in English and Chrome thinks the AMP page is in Turkish and wants to translate? How to resolve?

Example Thread - http://pnwmoto.com/amp/2425.html

And thanks for building this mod!
Sorry, I forgot to tell you need to edit the "ampthread" template and change
Code:
<html amp lang="tr">
to
Code:
<html amp lang="en">
or to your language code. (de,fr,ro, etc...)
Reply With Quote
Благодарность от:
beansbaxter
  #18  
Old 11-01-2016, 02:51 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
Sorry, I forgot to tell you need to edit the "ampthread" template and change
Code:
<html amp lang="tr">
to
Code:
<html amp lang="en">
or to your language code. (de,fr,ro, etc...)
You beat me to it! I found out where the problem was happening, made the edit, and came back to this thread to find you already posted a fix. Thanks!
Reply With Quote
  #19  
Old 11-01-2016, 03:03 PM
beansbaxter's Avatar
beansbaxter beansbaxter is offline
 
Join Date: May 2005
Location: Seattle
Posts: 96
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great everything works...

I too am running vBSEO. Not sure if this is possible, is there a way to change the AMP permalink structure to match up with vBSEO URL's?

And to convert the vBSEO Printable Thread URL's to the AMP version?

Examples below:

--

Currently, the vBSEO Print Thread structure is:
Code:
[forum_title]/[thread_id]-[thread_title]-print.html
Can it be changed to the following:
Code:
[forum_title]/[thread_id]-[thread_title]-amp.html
--

Currently, the vbSEO Print Thread Pagination:
Code:
[forum_title]/[thread_id]-[thread_title]-[thread_page]-print.html
Can it be changed to the following:
Code:
[forum_title]/[thread_id]-[thread_title]-[thread_page]-amp.html
--

And then how to change the AMP permalink to match up?

Thoughts?
Reply With Quote
  #20  
Old 11-01-2016, 03:17 PM
NeutralizeR NeutralizeR is offline
 
Join Date: Aug 2005
Posts: 355
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

AMP version of threads are unaffaced by vBSEO on my setup. I guess you are tying to make vBSEO powered AMP threads. It will require some edits in vbseo\includes.

You currently have two canonical tags on your AMP threads. Remove the one in ampthread template. Check my second post, edit your pagenav template.

Finally, you should remove <base href...> tag from your AMP threads. I think it is added by vBSEO, too.

You must see the "AMP validation successful." message in your developer console log.

http://pnwmoto.com/amp/2425.html#development=1

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

Once Googlebot crawls your AMP thread, (and if it returns valid AMP status code) Google will save a copy of your page to their servers.

So, when Google pushes AMP content for all kind of websites to mobile search results (soon), your AMP thread will be served via Google. This is what I know and I did not make any extra SEO efforts for AMP threads, based on this information.
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 10:10 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.05789 seconds
  • Memory Usage 2,390KB
  • 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
  • (14)bbcode_code
  • (5)bbcode_php
  • (2)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
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (14)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)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