#187 – Single Reviews Template

Posted in ‘weeblrAMP’
This is a public ticket. Everybody will be able to see its contents. Only enter usernames, passwords or any other sensitive information in the Private information field.
Monday, 09 December 2019 20:55 UTC
flashwebcenter
 Hello,
I tried to override this template /layouts/weeblramp/frontend/amp/contents/wc_single_reviews.php but it does not work.
I have other templates working fine. I am attaching a screenshot to see them.
Monday, 09 December 2019 21:32 UTC
flashwebcenter
Tuesday, 10 December 2019 10:30 UTC
wb_weeblrpress
Hi

Indeed this one is a bit special. It's not rendered by weeblrAMP (which would allow the override) but instead we provide that path to WooCommerce itself which then does the rendering (and does not take template overrides into account).

So in addition to making your override, you must also register it with WC:

// filter reviews template
add_filter(
	'comments_template',
	function($template) {
		if ( is_woocommerce() && Weeblramp_Api::isAmpRequest() ) {
			$template = __DIR__ . '/layouts/weeblramp/frontend/amp/contents/wc_single_reviews.php';
		}

		return $template;
	},
	100
);


This code goes into your weeblrAMP function file, in /wp-content/themes/{active_theme_or_child_theme}/weeblramp/functions.php

Note that weeblrAMP own hook handler is registered with priority 99, so your must have a higher one, like 100 as in the example above. Note also that because you must provide to WC the fill file to the comment/review display template, you're free to put that file anywhere you want.

This does allow to override the review display. As for your other comment, I'm not sure what you mean by "wiggles at the bottom". I have loaded, for instance,this page of the demo site on: desktop Brave, desktop firefox, desktop chrome, mobile brave, mobile Chrome and I cannot see any visual issue anywhere on the page. Maybe it's a matter of viewing the page at a specific screen size?
Can you provide more details on how you test this (ie device, width, browser,...)?

Best regards
 
Tuesday, 10 December 2019 18:15 UTC
flashwebcenter
Hello,
Thank you for your help. My old testing on my local for override the theme template it does not count. I see this message (We could not install the mu-plugin used by weeblrAMP to disable other plugins on AMP pages, which prevent using this feature. This usually happens when your server configuration prevents weeblrAMP to write in the WordPress MU-plugin directory. Your hosting company should be able to fix that.)

On my live site when I go to wp-admin/admin.php?page=weeblramp-settings under Theme Management and check Disable theme on AMP pages, I can't override any template.
Also /wp-content/themes/{active_theme_or_child_theme}/weeblramp/functions.php never got it to work.

To get it to work, I had to uncheck Disable theme on AMP pages under Theme Management and add everything to functions.php in my active theme.
// filter reviews template
add_filter(
	'comments_template',
	function($template) {
		if ( is_woocommerce() && Weeblramp_Api::isAmpRequest() ) {
			$template = __DIR__ . '/weebramp/layouts/weeblramp/frontend/amp/contents/wc_single_reviews.php';
		}

		return $template;
	},
	100
);


Maybe there is something in the database needed to be deleted so the fix you did will take a place.

About the (wiggles at the bottom). It is only on a product page with comment. It is only on a touch screen. It does not have any a specific screen size. You don't see it when you just scroll down, you have to interact with the page by swiping horizontally. I attached a screen shot from my cell phone.
Wednesday, 11 December 2019 08:23 UTC
wb_weeblrpress
Hi

Maybe there is something in the database needed to be deleted so the fix you did will take a place.
Nope.

I see this message (We could not install the mu-plugin used by weeblrAMP to disable other plugins on AMP pages, which prevent using this feature. This usually happens when your server configuration prevents weeblrAMP to write in the WordPress MU-plugin directory. Your hosting company should be able to fix that.)
This means a significant part of weeblrAMP is missing and of course it cannot operate normally.

This indicates that on your server weeblrAMP was not able to copy the mu-plugin it uses for various things to its proper location (/wp-content/mu-plugins). This usually happens because of improperly file access permissions. Your hosting company may help here again.

You can fix that yourself by manually copying (note the name change):

/wp-content/plugins/weeblramp/helper/mu_plugins_handler.php.inc
to
/wp-content/mu-plugins/weeblramp_plugins_handler.php

Again, incorrect file permissions (the PHP process is not allowed to write to some valid folders) is likely something that needs to be fixed or you risk being faced with similar issues with other plugins or features down the line.

About the (wiggles at the bottom). It is only on a product page with comment. It is only on a touch screen. It does not have any a specific screen size. You don't see it when you just scroll down, you have to interact with the page by swiping horizontally. I attached a screen shot from my cell phone.
I think it's an apple/safari thing (it's called "the new Internet Explorer" for a reason!).

When testing the 1st time around, I did all that as I mentioned and no such thing is happening on any of the phones I tested or when using developer tools. Actually, you're not supposed to even be able to slide sidewise as the main container occupies 100% of the width.

I'll try to put my hands on an Apple device to test with it but that won't happen today.

I found the problem coming from this line of code: (WeeblrampFactory::getThe( 'WeeblrampModel_Assetscollector' ) ->addStyle( 'comments' )->addStyle('form');). So I thought, “Some CSS, that's good news. “ I deleted everything in this file. The
This instructions load 2 CSS bits: the one for comments (to show comments) and the one for forms (to show the reviewing input field). You can better identify the source by using only one or the other, ie replace this instruction with:

WeeblrampFactory::getThe( 'WeeblrampModel_Assetscollector' ) ->addStyle( 'comments' );


and then with:

WeeblrampFactory::getThe( 'WeeblrampModel_Assetscollector' ) ->addStyle('form');


This can narrow down the issue to only one of the CSS files.

Best regards

 
Thursday, 12 December 2019 03:56 UTC
flashwebcenter
Hello,
Thank you for the update.
This means a significant part of weeblrAMP is missing and of course it cannot operate normally. This issue it is on my local, I am not getting any messages on live and I fixed it as you recommended. All the testing I am doing it is on live.

The issue I have here if you want to override weeblramp templates in your theme, you can't check Disable theme on AMP pages under Theme Management. Not sure what is the cause. I will have to do a fresh install for WP and test it. As long as I can override the templates, it is fine with me. There is no conflict between my active theme and google amp pages. All pages are validated.

Also I did try to narrow which css file for the wiggly page, when I removed comments.css it was wiggling the same. When I removed form.css it was wiggling a little bit. When I removed the two files. The screen does not wiggle at all.

Thank you for your help.
Thursday, 12 December 2019 10:43 UTC
wb_weeblrpress
Hi

This issue it is on my local, I am not getting any messages on live and I fixed it as you recommended
This is because your local setup does not have the permissions issue that you have on your live site. weeblrAMP (that is any PHP code running on the server) should be able to copy a file to the /wp-content/mu-plugin but on your live server that does not seem possible.

The issue I have here if you want to override weeblramp templates in your theme, you can't check Disable theme on AMP pages under Theme Management. Not sure what is the cause. I will have to do a fresh install for WP and test it
Yes, that would be a good idea. However as long as you get an error message at some point (such as the install-time message above) then the problem needs to be addressed before spending time on other things because any such error may/should/will have consequences, making your testing and further work possibly useless.

Also I did try to narrow which css file for the wiggly page, when I removed comments.css it was wiggling the same. When I removed form.css it was wiggling a little bit. When I removed the two files. The screen does not wiggle at all.
I have not been able to reproduce that for I lack Apple devices. The only one I could find lying around is an old IPad 2 mini from 2013. There's no wiggling or any abnormal display when using the form to comment - although on that wider display it's indeed possible to scroll horizontally.

Best regards

 
This ticket is closed, therefore read-only. You can no longer reply to it. If you need to provide more information, please open a new ticket and mention this ticket's number.