Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#11 2019-12-14 15:55:49

Myusername
Member
Registered: 2019-12-12
Posts: 44

Re: Two future feature suggestions

etc wrote #320520:

Sorry, what do you mean by AMP feature? As I get it, AMP is kinda restricted HTML framework (promoted by Google) that you are free to use in txp. You would just need to create/import a theme respecting AMP standards and keep to it in all content you publish. But there is no way to magically turn a general HTML into AMP without breaking something.

So, what would you expect from txp core AMP-wise? We could add some attribute to txp image tags to generate <amp-img /> instead of <img />, the rest is up to you. You’ve got a full and easy control on your templates with txp.

I think I would expect what the plugin already does, but as I told Stef, it may stop working in the future, and a site without AMP does not currently appear on the main slide of google searches, causing the site without AMP fique em big disadvantage.

AMP pages do not support any kind of javascript in your HTML, as well as any inline styles. In addition to several other requirements, and this all makes using the plugin necessary. (At least I think, if you have another way to do what I described above easily, I would like to know.) What the plugin basically does is make you have posts with “/amp/” at the end of the URL (as an alternate URL). It also makes it possible to use a conditional tag like this <txp:if_variable name="pat_amp" value="1"> to control what should be shown on the AMP page, and what should NOT be shown on AMP pages.

In Wordpress, for example, there is an official AMP plugin.

Anyway, I’m just giving a more amateur view of things.

Last edited by Myusername (2019-12-14 16:03:47)

Offline

#12 2019-12-14 16:58:32

etc
Developer
Registered: 2010-11-11
Posts: 3,580
Website

Re: Two future feature suggestions

Myusername wrote #320526:

In Wordpress, for example, there is an official AMP plugin.

You don’t really need any plugin to make a AMP site with txp. The simplest way is to serve all pages as AMP, modern browsers have no problem to output them. To this end you just need to create a txp Page like

<!doctype html>
<html ⚡>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,minimum-scale=1">
  <link rel="canonical" href="<txp:page_url context />">
  <title>AMP Website Demo</title>
  <script async src="https://cdn.ampproject.org/v0.js"></script>
</head>
<body>
  <txp:article>
    <h2><txp:permlink><txp:title /></txp:permlink></h2>
    <amp-img src="https://unsplash.it/400/300?image=11"
             width="400"
             height="300"
             alt="a sample image">
    </amp-img>
    <txp:body />
  </txp:article>
</body>
</html>

Then assign this page to all sections, publish few articles and that’s all. The layout will be very basic and unstyled, but your site is AMP-compatible as long as your articles body is. Now you can progressively enhance this Page with menus and other AMP components. This will require some work and knowledge, but it’s basically what WP plugin is – a template.

Offline

#13 2019-12-14 18:05:26

Myusername
Member
Registered: 2019-12-12
Posts: 44

Re: Two future feature suggestions

etc wrote #320530:

The layout will be very basic and unstyled, but your site is AMP-compatible as long as your articles body is.

I don’t mean that you are wrong, but in fact, it is not just the body of the article that needs to be compatible to have an AMP page.

Literally the whole page needs to be compatible: It is not allowed to use javascript, for example, whether it is inside <head> or at the end of <body>, there are also CSS commands that are not allowed, such as display: table.

You gave a good example of an AMP page, however, you would have to limit my main page not to use some CSS commands. Also, what would you do if you wanted to use a library like Jquery?

Here comes the alternate version of the page I mentioned earlier. So you can have your page showing all the power you want, and another version with AMP, which would be extremely more limited and simple. Of course, it will not be used by default, it will only be used when the user comes from Google search slides.

But the point here is that you can have an alternate AMP page from existing pages, displaying or hiding anything you want, which can only be accessed by using “/amp/” at the end of any publication’s URL.

I’m working on the look of an AMP site on Textpattern using the “pat_if_amp” plugin, it will soon be ready and I’ll show you how it works, if you want.

Last edited by Myusername (2019-12-14 18:06:53)

Offline

#14 2019-12-14 18:20:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,120
Website

Re: Two future feature suggestions

If the large part of pat_if_amp is detecting if the URL contains /amp or not, you can probably do that with native tags now. Check the URL at the top of every page and set a <txp:variable> then test it at key points on your page via <txp:if_variable> to switch content. Maybe make up your own shortcode tag in a form. Up to you.

You could then serve a different, simpler stylesheet. Only key bits of content. Skip JavaScript. Whatever you want.

There’s so much you can do without plugins once you start weaving the power of the tags we introduced and enhanced in Textpattern 4.7.+.

Last edited by Bloke (2019-12-14 18:20:46)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#15 2019-12-14 19:27:08

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 7,750
Website

Re: Two future feature suggestions

Bloke wrote #320534:

If the large part of pat_if_amp is detecting if the URL contains /amp or not, you can probably do that with native tags now. Check the URL at the top of every page and set a <txp:variable> then test it at key points on your page via <txp:if_variable> to switch content.

I, and possibly Myusername, would appreciate a tags example here:).

Also, excluding the size of the images and some proprietry tags and specs, what I’m not sure about is the difference between AMP and the media css query. Maybe I am understanding it wrongly but isn’t AMP designed to serve lighter stylised content to mobile devices? Found it. Basically AMP uses Google as a proxy.

AMP pages are served to the user from the Google AMP cache.

Last edited by colak (2019-12-14 19:46:31)


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#16 2019-12-14 23:23:14

Myusername
Member
Registered: 2019-12-12
Posts: 44

Re: Two future feature suggestions

Bloke wrote #320534:

If the large part of pat_if_amp is detecting if the URL contains /amp or not, you can probably do that with native tags now. Check the URL at the top of every page and set a <txp:variable> then test it at key points on your page via <txp:if_variable> to switch content.

I don’t know if it’s the best (and right) way to make it work. But I did it this way:

<txp:if_individual_article not>
 <txp:output_form form="page_default" />
<txp:else/>
 <txp:variable name="foo" value='<txp:site_url trim="/"/><txp:page_url/>' />
 <txp:if_variable name="foo" value='<txp:permlink/>/amp/'>
  <txp:output_form form="page_amp" />
 <txp:else/>
  <txp:if_variable name="foo" value='<txp:permlink/>/amp'>
   <txp:txp_die status="301" url='amp/' />
  </txp:if_variable>
  <txp:output_form form="page_default" />
 </txp:if_variable>
</txp:if_individual_article>

Last edited by Myusername (2019-12-15 08:09:32)

Offline

#17 2019-12-15 10:19:41

etc
Developer
Registered: 2010-11-11
Posts: 3,580
Website

Re: Two future feature suggestions

Myusername wrote #320533:

however, you would have to limit my main page not to use some CSS commands. Also, what would you do if you wanted to use a library like Jquery?

I’ve heard Google recommends that AMP and not AMP versions match as close as possible and ranks higher ‘AMP only’ sites. So if you are developing a new site…

I’m working on the look of an AMP site on Textpattern using the “pat_if_amp” plugin, it will soon be ready and I’ll show you how it works, if you want.

Sure, please share.

Offline

#18 2019-12-15 10:32:31

etc
Developer
Registered: 2010-11-11
Posts: 3,580
Website

Re: Two future feature suggestions

Myusername wrote #320543:

I don’t know if it’s the best (and right) way to make it work.

You could try also

<txp:evaluate query='contains(<txp:page_url escape="quote" />, "/amp")'>
    AMP page
<txp:else />
    regular page
</txp:evaluate>

Or register preg_match function in <txp:evaluate /> for fine-grained tests.

Offline

Board footer

Powered by FluxBB