Total head scratcher: same page in different language scores differently. Is it me? Is it a bug? - multilingual

Our website uses an optional language parameter for displaying pages in either English or Spanish, for instance:
https://www.spotmodel.com/product_info.php?products_id=17442&language=en
https://www.spotmodel.com/product_info.php?products_id=17442&language=es
Of course, code is exactly the same, performance is exactly the same, and page generation speed is exactly the same (just selecting different rows for page text locales)
BUT
In PageSpeed, mobile tab, pages with "language=en" consistently score about 10 points LESS than pages with "language=es" (about ninetysomething in "es", about eightysomething in "en").
According to my tests, it happens on every single page (within the bounds of the small score variations). The generated code is exactly the same (except the small text changes), html sizes are also similar or even bigger in the ES version (370k EN vs 377k ES), functions do NOT perform anything differently.
Problem is that, by default, if the parameter is not found, the page served is the English version, hence i'm getting an "orange" score most of the times, instead of the nice "green" on the Spanish pages.
Any clues on what I'm missing? Is it a bug in lighthouse parsing pages with <html lang=es>

Related

ADNStoreFront Multistore AddtoCartForm function crashing page

I am trying to modify an existing XML package of Aspdotnetstorefront Multistore. It's an internal XML package to show the variants of a certain product. What I did to start with was to copy-paste the whole code as is and throw it into a new custom XML package. The problem is that it works fine in the original package but not in the copied package. When I try to run it the function "AddtoCartForm" crashes the page and show the following error while display in red the line that contains the function call:
An HtmlHelper is required for this method. Make sure to specify one when you call the RunXmlPackage method
The format of the function is:
<xsl:value-of select="aspdnsf:AddtoCartForm(ProductID, VariantID, 1, 1, $SelectedSize, $SelectedColor)" disable-output-escaping="yes"/>
I removed the line with the function just to be sure and then everything else works fine. I have no idea what's wrong here. Everything is identical unless by the structure of the url which calls the package:
For the internal package it is: \product\123456
For the custom package it is: \topic\packagename?ProductID=123456
I checked the XML produced by the SPs, the runtime and requested data and it's basically the same in both cases. The ProductID and VariantID values are there. SelectedColor and SelectedSize are not in the XML (not even in the internal package) so it may be just providing null value and probably it's not necessary anyway.
And there is more. If I supress the productid value from the url like this:
\topic\packagename
It won't crash the page (but also won't render because there will be not be any value to process).
In any way I cannot see why it wouldn't work just passing the variable in the querystring (that is basically what it does in the original package even in a different format) and the var value (productid) it getting there. However it seems that it is indeed the url format that is not pleasing the package but it doesn't make too much sense to me. I am over this for several days already and nothing I do seem to produce any positive result. :-(
I looked up online for some documentation but didn't get lucky and didn't find absolutely anything. In extreme cases I try to reach the Vortx support (and they usually answers me giving some valueable clue) but this time it seems that for this specific issue there will not be any help unless I pay an obscene hour fee and unfortunately it's out of question... LoL!
Any idea?
UPDATE: We don't use Multistore regular search tool. Due to the nature of our products (recycled car parts) we have a custom search tool that will try to find 'similar' items that MAY fit the user needs when we don't have the EXACT part. I don't know if you are ware of but several mechanical car parts are interchangeable among different models and makes (like alternators, AC compressors, battery, suspension, cooling system, etc), so when one of our customers needs a part to fix his car he won't tell us the part code; instead he will tell us the car model, year, and generic name of the part so we will try to find the part for him. It does mean that a certain Corolla part will fit perfectly in a Honda Accord and so on. Some times we have some parts in stock that MAY fit his car but we are not absolutely sure. When it happens we will show those parts for the customer and he will decide if he can take his chances. For the sake of customer comfort we want to show all these parts in the same page, but since they normally are variants of different products we cannot use the regular product page for this purpose (because the product page will only show variants of ONE product at time). For this reason I am going to write a package - a modified version of the product page - that will do that but I am struggling with the AddtoCartForm function. In fact I JUST found a workaround by adding the item to the cart accessing directly the /shoppingcart/addtocart script and now my problem is being to force it return to a specific url after to add the item to the shopping cart...
The error has to do with the topic token able to properly get html helper filled out.
I do question why testing is being done on a topic. To test a new product xmlpackage I normally change change the xmlpackage for just one product in a testing environment.
If chaning the product xmlpackage isn't possible then I suggest using the XmlPackageController/engine instead. Which is documented on page https://help.aspdotnetstorefront.com/1000/xml_packages.htm under the heading of "Invoking XML Packages by Themselves". If using the XmlPackageController make certain that the allowengine attribute is set to true in the xmlpackage otherwise that will throw an error as well.

React Generating pdfs on components

I want to be able to generate a pdf of the page. It needs to satisfy a few requirements
It must maintain the same styling (What is displayed on page must be what is displayed on pdf)
The pdf that is displayed/generated must be in letter size format (8.5in x 11in)
I've looked at a few libraries, but have not found one that meets these conditions
react-pdf - This allows you to state a paper size such as "A4" and it does meet condition 1. But it has limitations in that it forces you to use their basic components. You cannot put div and I imagine any other things generated by other libraries.
react-to-pdf - This will let me place my own components inside the pdf and it seems to let you choose paper size. However, it does not meet condition 1, and things may get cut off.
If anyone can chime in, I would greatly appreciate it. Thanks!

Interpolating custom data onto a PDF

I am building an Angular test preparation app (with Laravel 5.1 API). One of the requirements is to allow the user to print a certificate of achievement.
The client wants the person's name and credentials interpolated into the document (e.g., highlighted below). Here is a snapshot of the PDF template they sent:
The way I'm handling PDF viewing is simply by storing the file on S3 and giving them a link to that file.
Interpolating information into a PDF doc doesn't seem trivial and I haven't found much information on programmatically allowing this, but there are tools like DocHub, that allow you do edit while viewing the PDF.
I'm interested in learning:
is doing this programmatically trivial?
are there 3rd party tools I'm unaware of?
would I even be able to send this information along to the S3 link to interpolate in the first place?
Using PDF as a format for editing is usually a bad choice. If you have a form with fixed fields, then it's easy. Create a PDF template with an interactive form. In this form, based on AcroForm technology, you'll define fields with fixed coordinates, and a fixed size. You can then add content to these fields.
One major disadvantage with this approach is the lack of flexibility. Did you notice that I used the word "fixed" three times in the previous paragraph? If text doesn't fit the predefined field, you're out of luck. If the field is overdimensioned, you'll end up with plenty of white space. This approach is great if you can predict what the data will be like. A typical use case is a ticket or a voucher. For instance: the empty form is a really nice page, with only a couple of fields where an automated system can put a name, a date, a time, and a seat number.
This isn't the best approach for the example you show in your screen shot. The position of every line of text, every word, every character is known in advance. If you want to replace a short word with a long word (or vice-versa), then all those positions (of each line, of the complete page, possibly of the complete document) need to be recalculated. That's madness. Only people with very poor design skills come up with such an idea.
A better idea, is to store the template as HTML. See for instance chapter 5 of iText's pdfHTML tutorial, where we have this snippet of HTML:
<html>
<head>
<title>Invitation to SXSW 2018</title>
</head>
<body>
<u><b>Re: Invitation</b></u>
<br>
<p>Dear <name>SXSW visitor</name>,
we hope you had a great SXSW film festival experience last year.
And we would like to invite you to the next edition of SXSW Film
that takes place from March 9 until March 17, 2018.</p>
<p>Sincerely,<br>
The SXSW crew<br>
<date>August 4, 2017</date></p>
</body>
</html>
Actually, it's not really HTML, because the <name> tag and the <date> tag don't exist in HTML. All HTML processors (browsers as well as pdfHTML) ignore those tags and treat their content as if the tag was a <span>:
It doesn't make much sense to have such tags in the context of pure HTML, but it does make a lot of sense in the case of pdfHTML. With pdfHTMLL, you can configure custom tags, and have a result that looks like the PDFs shown below:
Look at the document for "John Doe" and compare it with the document for "Bruno Lowagie". The name "John Doe" is much shorter than my name, hence more words fit on that first line. The text flows nicely (we could also have chosen to justify the text on both sides). This "flow" is impossible to achieve with your approach, because you will never get a PDF template to reflow nicely.
OK, I get it, you probably say, but what about the practical aspects? You talk about a Java / .Net library, but I am working with Laravel and Angular.js. First, let me tell you that I don't think you'll find any good PDF tools for Laravel or Angular.js, because of the nature of PDF and those development environments (in my opinion, those technologies don't play well together). Regardless of my opinion, this shouldn't be much of a problem for you because you work in an Amazon environment. AWS supports Java, and the Java code needed to get pdfHTML working is minimal. Most of the code samples I wrote for the pdfHTML tutorial are shorter than 15 lines. So why not try Java and pdfHTML?
If you're already using Amazon services, why not use an amazon lambda function, in combination with iText7 (java), to generate the pdf on demand?
That way, you are guaranteed that the pdf is correct, and has nice layout every time.
Generating the pdf can either be done by:
converting HTML,
programmatically creating your entire document,
filling and flattening an XFA form.
I think for your use-case, either option 1 or 2 are the most sustainable.

Phones dialing wrong number from tel-hyperlink

We received a complaint that some visitors to our website are dialing the wrong number to get in contact with us.
Our website has a hyperlink in the following form in the footer:
Call us at 12345678
Note that the "+47" (international code) is NOT displayed visually, it is only included in the hyperlink. But now it turns out a limited number of people (circa one a day) is actually calling a private local number at 47123456. Not many considering the size of our business, but still a major nuisance for the family receiving these calls.
The people calling say they just pressed the link to dial.
Has anybody else had these problems? Is anybody aware of mobile phones that do not properly support the tel hyperlink? Any suggestions for a solution? (Apart from changing our or their phone number, of course.)
There are different ways smart phones pick a telephone number.
some are reading the text of your website - some use the tag
on my first try: I would add the +47 to the displayed telephone number
on my second try (or both together): I would replace +47 with 0047 (its norway - or?)
and before posting i got a third idea: which encoding has the webserver and which encoding has the html / PHP page in sourcecode? Both UTF-8 or something else?
Maybe your server is sending it in a different way than the website is created and somehow some smartphones can't handle it correctly.
The problem here is pretty simple: this is the URL-Encoding.
The + char is an reserved character within the URL and represents an space.
To get an actual + sign replace it with the URL encoded version: %2B
See Links for details:
Wikipedia
W3Scools

search results and pagination wrong if embedded view or block in result set

I have two content types (in a Drupal 7.20 environment) which embed views or blocks. When I allow those content types in search results, the results page goes sideways whenever those content types are represented in the result set: the pager shows a different number of total pages from one results page to the next, or disappears entirely after I hit Next (!), fewer than 10 results show per page (yet there's a pager...), etc., etc.
If I disallow those content types (via Custom Search), I don't see any problems with pagination, etc.
What I have noticed is that the actual views/blocks get executed when the search results page is constructed - it's not merely a matter of hits being found in the search_index table.
Anybody know how to address this problem?
(I've searched through stackoverflow, and issues for Search and Custom Search on Drupal.org - no joy.)
Thanks in advance,
Lee
[Edit: fixed a couple of typos...]
[3/17/13 Edit: The problem turns out to be due to the pager for the view or block that is included in the search result set. If the view is in the result set, but doesn't have a pager, there is no problem. My solution, therefore, is to detect that I'm on a search results page in hook_views_query_alter() (by looking at the request URI) and set
$view->items_per_page = 0;
which effectively gets rid of the view's pager.
[I didn't realize I could answer my question - not sure how that's different from editing the question to include the answer, but I'll put my answer here as well, anyway.]
The problem turns out to be due to the pager for the view or block that is included in the search result set. If the view is in the result set, but doesn't have a pager, there is no problem. My solution, therefore, is to detect that I'm on a search results page in hook_views_query_alter() (by looking at the request URI) and set
$view->items_per_page = 0;
which effectively gets rid of the view's pager.

Resources